https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100650
Damian Rouson <damian at archaeologic dot codes> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |damian at archaeologic dot codes --- Comment #1 from Damian Rouson <damian at archaeologic dot codes> --- Here's a shorter reproducer: % cat reshape-array-constructor.f90 type foo_t integer, allocatable :: bar(:) end type type(foo_t) foo(2,1) integer :: i, j, n(2,2,1) = reshape([-1,-1,1,1], [2,2,1]) foo = reshape([([(foo_t(merge(0, 1, n(:,i,j) > 0)), i=1,2)], j=1,1)], [2,1]) print *, merge(0, 1, n(:,1,1) > 0), foo(1,1)%bar print *, merge(0, 1, n(:,2,1) > 0), foo(2,1)%bar end % gfortran reshape-array-constructor.f90 % ./a.out 1 1 -358465392 24440 0 0 -358465392 24440 % gfortran --version GNU Fortran (Homebrew GCC 13.1.0) 13.1.0 Another workaround in the above example is to make n a constant array via integer, parameter :: n(*,*,*) = reshape([-1,-1,1,1], [2,2,1])