Segfault with sourced allocation of large array with status

The following program, compiled with “pgfortran -mcmodel=medium …” leads to a run-time error on Linux x86-64 when the array cannot be allocated.

allocatable i(:)
allocate(i(HUGE(1_8)),source=0,stat=j)
end

Not recommended that you use -mcmodel=medium, if you are
not statically allocating the arrays, as in

integer I(HUGE(I_8))

because every other object linked needs to be compiled
-mcmodel=medium.

But do add

-Mlarge_arrays

because you need 64-bit integer arithmetic to calculate array-index-to-offset calculations.

In either case, if you have the ‘stat’ argument, the allocation should fail and the stat should be set to a known value.

I have filed TPR 24942 to address this.