This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/78152] [6/7 Regression] coarray and associate
- From: "sgk at troutmask dot apl.washington.edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 30 Oct 2016 23:06:50 +0000
- Subject: [Bug fortran/78152] [6/7 Regression] coarray and associate
- Auto-submitted: auto-generated
- References: <bug-78152-4@http.gcc.gnu.org/bugzilla/>
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.