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

            Bug ID: 127751
           Summary: ALLOCATE (stat=) of a coarray does not report an
                    exhausted shared memory pool
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jvdelisle at gcc dot gnu.org
  Target Milestone: ---

When the shared memory pool (GFORTRAN_SHARED_MEMORY_SIZE) cannot hold
the coarray, ALLOCATE returns stat=0 and the first access to the
coarray segfaults, instead of the allocation failing with a nonzero
stat (or error termination without stat=).

---- pool_stat.f90 ----
program pool_stat
  implicit none
  integer(8), allocatable :: a(:)[:]
  integer :: st

  st = 0
  ! 8 MiB per image; more than the shared memory pool for 8 images
  allocate (a(1048576)[*], stat=st)
  if (st == 0) then
    a = this_image ()
    print '(a,i0,a)', 'image ', this_image (), ': allocated'
  else
    print '(a,i0,a,i0)', 'image ', this_image (), ': stat ', st
  end if
end program pool_stat

See PR127738 where originally reported.

Reply via email to