https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112764

--- Comment #5 from anlauf at gcc dot gnu.org ---
(In reply to martin from comment #4)
> (In reply to anlauf from comment #1)
> > Confirmed.
> > 
> > F2018:11.1.3.3 has:
> > 
> > "The associating entity does not have the ALLOCATABLE or POINTER attributes;
> > it has the TARGET attribute if and only if the selector is a variable and 
> > has
> > either the TARGET or POINTER attribute."
> 
> I was not sure, whether this formulation also covers array sections.

The following example has apparently always been legal, is accepted and works:

  integer, pointer             :: x, y(:)
  integer, allocatable, target :: z(:)
  allocate (y(2), z(3))
  y = 42
  x => y(2)
  print *,x
  z = 23
  x => z(2)
  print *,x
end

I think this is covered by F2018:8.5.17 TARGET attribute, although I find
the text somewhat hard to understand.  Like:

"If an object has the TARGET attribute, then all of its nonpointer subobjects
also have the TARGET attribute."

IIUC that would cover array sections.

Reply via email to