This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/78152] [6/7 Regression] coarray and associate


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

--- Comment #3 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
I believe the posted code is neither conforming nor nonconforming.
It has found a defect in the Fortran 2008 standard.  The code can
be written as

subroutine co_assoc
  implicit none
  integer, parameter :: p = 5
  real, allocatable :: a(:,:)[:,:]
  allocate (a(p,p)[2,*])
  associate (i => a(1:p, 1:p))
  end associate
end subroutine co_assoc

where I changed 'program' to 'subroutine'.  gfortran reports

% gfc -c -fcoarray=single a.f90
a.f90:7:29:

   associate (i => a(1:p, 1:p))
                             1
Error: Variable 'i' at (1) is a coarray and is not ALLOCATABLE,
SAVE nor a dummy argument

Now, looking at the standard one finds

   8.1.3.3 Attributes of associate names
   ...
   The cobounds of each codimension of the associating entity are
   the same as those of the selector.

If one assumes that an entity with cobounds and codimension is a
coarray, then 'i' is a coarray.  But, by F2008:C526, one has

   C526 A coarray or an object with a coarray ultimate component
        shall be a dummy argument or have the ALLOCATABLE or SAVE
        attribute.

'i' is clearly not a dummy argument.  From 16.5.1.6

   If the selector is allocatable, it shall be allocated; the
   associate name is associated with the data object and does
   not have the ALLOCATABLE attribute.

'i' does not have the ALLOCATABLE attribute.  By inspection, one
can see that 'i' also does not have the SAVE attribute.

In thinking about it, 8.1.3.3 shows that the standard intends
to permit a coarray in an ASSOCIATE statement, but C526 imposes
very limited conditions. 

Someone needs to submit an interpretation request to J3.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]