(j3.2006) Pointers, arguments, and the TARGET attribute

Cohen Malcolm malcolm
Tue Jun 14 01:55:48 EDT 2016

There does not seem to be any doubt here.  The pointers are associated with 
the dummy argument, just as the standard says.  That they are not Completely 
Totally and Utterly Associated with all the types the same and all the array 
elements in the same order is an elephant.

That is, given


  P1 => DUMMY(:)
  P2 => DUMMY(::2)

you cannot seriously be interpreting the standard to say that on return P1 
remains associated but P2 goes undefined, just because it is not associated 
with the whole shooting match.

As far as I can see you cannot interpret the association being referred to 
as including subobject association, because otherwise you run straightaway 
into a contradiction.  That means that it cannot be so interpreted!  The 
only possible interpretation is that a pointer to a subobject remains 
associated when a pointer to the whole object would remain associated, as 
that is the only interpretation that is consistent with the rest of the 
standard (by "consistent", I mean "is not contradicted by").

Therefore, Not A Problem.


-----Original Message----- 
From: Van Snyder
Sent: Tuesday, June 14, 2016 10:07 AM
To: fortran standards email list for J3
Subject: Re: (j3.2006) Pointers, arguments, and the TARGET attribute

On Tue, 2016-06-14 at 09:43 +0900, Cohen Malcolm wrote:
> >I asked this question last year.  There was no follow-up on the server.
> >
> >Should address subobjects?
> What makes you think this is broken?
> Is there some actual problem you are thinking about?
> With actual example code?
> In the absence of a definitive example we're left with a tricky-looking
> hypothetical.  Declining to answer seems like a good decision.
> Cheers,

module M

  type :: T
    integer :: I, J
  end type T

  type(t), save, target :: V
  integer, pointer :: P


  subroutine S1 ( A )
    type(t), intent(in), target :: A
    p => a%i
  end subroutine S

  subroutine S2 ( A )
    type(t), intent(in), target :: A
    call s1 ( a )
    ! Is p still associated with V%I?
    print *, p
  end subroutine S2

end module M

Assume S2 gets called with V as its argument. mentions "pointers ... associated with the dummy argument
remain associated with the effective argument."

Is P associated with V%I after "call S1 ( A )" in S2 completes?

The dummy argument and the effective argument both have the TARGET
attribute, and if an object has the TARGET attribute then so do its
subobjects, so the pointer assignment to P in S1 is allowed.

P has the wrong type to be associated with either the dummy argument or
the effective argument, and it's not associated with components of
either the dummy argument other than A%I or ones of the effective
argument other than V%I.

The question is whether a pointer associated with a subobject of the
dummy argument remains associated with a subobject of the effective
argument after execution completes. all refer to the dummy argument or effective argument,
without mentioning subobjects thereof.

J3 mailing list
J3 at mailman.j3-fortran.org

This e-mail has been scanned for all viruses by Star.

........................Malcolm Cohen, Nihon NAG, Tokyo. 

More information about the J3 mailing list