https://gcc.gnu.org/g:640cc22a44221f5e80efbf13cf948102040b5e93
commit r17-5678-g640cc22a44221f5e80efbf13cf948102040b5e93 Author: Jerry DeLisle <[email protected]> Date: Wed Oct 28 13:23:13 2026 -0400 fortran: Fix alloc_pool_exhausted_1 on 32-bit targets On 32-bit targets the array bound 2**37 did not fit in the index type and became zero, so the ALLOCATE succeeded and the test failed. Use a smaller size on 32-bit targets that still does not fit in the shared memory pool. Assisted-by: Claude Opus 5.5 PR libfortran/127751 gcc/testsuite/ChangeLog: * gfortran.dg/coarray/alloc_pool_exhausted_1.f90: Use a per-image size that fits the index type on 32-bit targets. Diff: --- gcc/testsuite/gfortran.dg/coarray/alloc_pool_exhausted_1.f90 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/gfortran.dg/coarray/alloc_pool_exhausted_1.f90 b/gcc/testsuite/gfortran.dg/coarray/alloc_pool_exhausted_1.f90 index 8f88b7e16444..75664f155b2a 100644 --- a/gcc/testsuite/gfortran.dg/coarray/alloc_pool_exhausted_1.f90 +++ b/gcc/testsuite/gfortran.dg/coarray/alloc_pool_exhausted_1.f90 @@ -5,13 +5,17 @@ ! nonzero STAT= instead of handing out memory past its end. program alloc_pool_exhausted_1 + use iso_c_binding, only: c_intptr_t implicit none + ! Per-image element count; kept in range of a 32-bit index and size_t + integer(8), parameter :: n = merge (2_8**37, 2_8**25, & + bit_size (0_c_intptr_t) == 64) integer(8), allocatable :: a(:)[:] integer :: st, nb if (num_images () < 2) stop - ! 1 TiB per image - allocate (a(2_8**37)[*], stat=st) + ! 1 TiB per image on 64-bit targets, 256 MiB on 32-bit targets + allocate (a(n)[*], stat=st) if (st == 0) stop 1 allocate (a(10)[*], stat=st) if (st /= 0) stop 2
