https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120431
Bug ID: 120431
Summary: SPREAD does not handle scalar argument and NCOPIES=-1
correctly
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: kargls at comcast dot net
Target Milestone: ---
Consider,
real :: arr
arr = 1
print *, spread(arr, 1, -1)
end
% gfcx -o z a.f90 && ./z
Operating system error: Cannot allocate memory
Integer overflow in xmallocarray
>From F2023, 16.9.197
Result Characteristics. The result is an array of the same type and type
parameters as SOURCE and of rank n + 1, where n is the rank of SOURCE.
Case (i): If SOURCE is scalar, the shape of the result is (MAX(NCOPIES,0)).
So, the result is a rank 1 zero-sized array.