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

Van Snyder Van.Snyder
Mon Jun 13 21:07:01 EDT 2016


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 12.5.2.4p8-12 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

contains

  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.

12.5.2.4p9 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.

12.5.2.4p8-12 all refer to the dummy argument or effective argument,
without mentioning subobjects thereof.





More information about the J3 mailing list