Each line of the following subroutine causes a run-time abort. Except for the one labeled gf1069. It works if literal constants are used in place of the nf* variables. Dick Hendrickson program try_gf1065 ! fails on Windows XP ! gcc version 4.4.0 20080312 (experimental) [trunk revision 133139] call gf1065(1, 2, 3, 4, 7, 8, 9) end SUBROUTINE GF1065(nf1,nf2,nf3,nf4,nf7,nf8,nf9) ! also 1066 thru 1070, 1069 works REAL RDA(10,9) REAL RCA1(90) integer ila(2) !gf1065 RDA(NF9:NF8, NF7:NF3) = RESHAPE(RCA1,(/0,0/), (/1.0/),(/2,1/)) print *, 'gf1065' !gf1066 rDA(NF9:NF8, NF7:NF3) = RESHAPE(rCA1,(/0,0/),ORDER=(/2,1/)) print *, 'gf1066' ILA(1) = 5 ILA(2) = 0 !gf1067 rDA(NF4:NF8, NF7:NF3) = RESHAPE(rcA1,ILA) print *, 'gf1067' !gf1068 RdA(NF4:NF8, NF7:NF3) = RESHAPE(RcA1,ILA,PAD=(/-1.0/)) print *, 'gf1068' ILA(1) = 0 ILA(2) = 5 !gf1069 this one works RdA(NF9:NF8,NF4:NF8)=RESHAPE(RcA1,ILA,(/-1.0/),(/NF2,NF1/)) print *, 'gf1069' ILA(1) = 5 ILA(2) = 0 !gf1070 RdA(NF4:NF8, NF7:NF3) = RESHAPE(RcA1,ILA,ORDER=(/NF1,NF2/)) print *, 'gf1070' END SUBROUTINE C:\gfortran:gfortran gf1065.f C:\gfortran:a Fortran runtime error: shape and target do not conform
Confirmed. I'll take a look at this.
We don't check for empty arrays in reshape. Should be fairly straightforward.
Created attachment 15496 [details] proposed patch Here's a patch. I'll regression-test and commit tomorrow, probably.
Subject: Bug 35960 Author: tkoenig Date: Sun Apr 20 19:56:07 2008 New Revision: 134490 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=134490 Log: 2008-04-20 Thomas Koenig <tkoenig@gcc.gnu.org> PR libfortran/35960 * intrinsics/reshape_generic.c (reshape_internal): If the size of the resized array is zero, as determined by the SHAPE argument, return early. * m4/reshape.m4: Likewise. * generated/reshape_i4.c: Regererated. * generated/reshape_i8.c: Regenerated. * generated/reshape_i16.c: Regenerated. * generated/reshape_r4.c: Regenerated. * generated/reshape_r8.c: Regenerated. * generated/reshape_r10.c: Regenerated. * generated/reshape_r16.c: Regenerated. * generated/reshape_c4.c: Regenerated. * generated/reshape_c8.c: Regenerated. * generated/reshape_c10.c: Regenerated. * generated/reshape_c16.c: Regenerated. 2008-04-20 Thomas Koenig <tkoenig@gcc.gnu.org> PR libfortran/35960 * gfortran.dg/reshape_zerosize_1.f90: New file. Added: trunk/gcc/testsuite/gfortran.dg/reshape_zerosize_1.f90 Modified: trunk/gcc/testsuite/ChangeLog trunk/libgfortran/ChangeLog trunk/libgfortran/generated/reshape_c10.c trunk/libgfortran/generated/reshape_c16.c trunk/libgfortran/generated/reshape_c4.c trunk/libgfortran/generated/reshape_c8.c trunk/libgfortran/generated/reshape_i16.c trunk/libgfortran/generated/reshape_i4.c trunk/libgfortran/generated/reshape_i8.c trunk/libgfortran/generated/reshape_r10.c trunk/libgfortran/generated/reshape_r16.c trunk/libgfortran/generated/reshape_r4.c trunk/libgfortran/generated/reshape_r8.c trunk/libgfortran/intrinsics/reshape_generic.c trunk/libgfortran/m4/reshape.m4
Fixed on trunk (no need to backport this to 4.3). Closing.
Subject: Bug 35960 Author: tkoenig Date: Fri Apr 25 20:11:19 2008 New Revision: 134677 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=134677 Log: 2008-04-25 Thomas Koenig <tkoenig@gcc.gnu.org> PR libfortran/35960 * m4/reshape.m4: Fix typo in last commit. * generated/reshape_i4.c: Regererated. * generated/reshape_i8.c: Regenerated. * generated/reshape_i16.c: Regenerated. * generated/reshape_r4.c: Regenerated. * generated/reshape_r8.c: Regenerated. * generated/reshape_r10.c: Regenerated. * generated/reshape_r16.c: Regenerated. * generated/reshape_c4.c: Regenerated. * generated/reshape_c8.c: Regenerated. * generated/reshape_c10.c: Regenerated. * generated/reshape_c16.c: Regenerated. Modified: trunk/libgfortran/ChangeLog trunk/libgfortran/generated/reshape_c10.c trunk/libgfortran/generated/reshape_c16.c trunk/libgfortran/generated/reshape_c4.c trunk/libgfortran/generated/reshape_c8.c trunk/libgfortran/generated/reshape_i16.c trunk/libgfortran/generated/reshape_i4.c trunk/libgfortran/generated/reshape_i8.c trunk/libgfortran/generated/reshape_r10.c trunk/libgfortran/generated/reshape_r16.c trunk/libgfortran/generated/reshape_r4.c trunk/libgfortran/generated/reshape_r8.c trunk/libgfortran/m4/reshape.m4