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

Paul Thomas <pault at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pault at gcc dot gnu.org

--- Comment #4 from Paul Thomas <pault at gcc dot gnu.org> ---
(In reply to Steve Kargl from comment #3)
> 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.

Hi Steve,

If you bypass the error for associate names, does such code run correctly?

Also, what do the other brands do? I am away from base at present but, as soon
as I am home, I will try the testcase with ifort.

Cheers

Paul

Reply via email to