Another testcase (from scratch) with undefined variable "j". Changed between 20170820 and 20170910 : $ cat z1.f90 program p integer :: i character(3) :: x data (x(j:i), i=1,2,2) /'a'/ print *, x end $ gfortran-8-20170820 -c z1.f90 z1.f90:4:28: data (x(j:i), i=1,2,2) /'a'/ 1 Warning: Unused initialization string at (1) because variable has zero length $ gfortran-8-20180204 -c z1.f90 *** Error in `.../x86_64-pc-linux-gnu/8.0.1/f951': double free or corruption (out): 0x0000000003f1fdd0 *** ... z1.f90:6:0: end internal compiler error: Aborted 0xb953ff crash_signal ../../gcc/toplev.c:325 0x6a70c7 free_expr0 ../../gcc/fortran/expr.c:451 0x6a717d gfc_free_expr(gfc_expr*) ../../gcc/fortran/expr.c:520 0x738566 gfc_free_symbol(gfc_symbol*) ../../gcc/fortran/symbol.c:3042 0x7386f3 free_sym_tree ../../gcc/fortran/symbol.c:3890 0x7386ea free_sym_tree ../../gcc/fortran/symbol.c:3888 0x738391 gfc_free_namespace(gfc_namespace*) ../../gcc/fortran/symbol.c:4045 0x73897c gfc_symbol_done_2() ../../gcc/fortran/symbol.c:4089 0x6dca58 gfc_done_2() ../../gcc/fortran/misc.c:267 0x6fffc6 translate_all_program_units ../../gcc/fortran/parse.c:6140 0x6fffc6 gfc_parse_file() ../../gcc/fortran/parse.c:6324 0x74686f gfc_be_parse_file ../../gcc/fortran/f95-lang.c:204
Confirmed, I see the ICE for all releases I have (4.5.0+).
Note that the DATA statement data (x(j:i), i=1,2,2) /'a'/ is not valid Fortran. Implied do objects, here x(j:i), are restricted by R538 (F08) to array elements, scalar structure component, or an implied-do. x(j:i) is an array section not an array element. But this may be a language extension that gfortran supports.
Some working variants/extentions with substring "x(i:i)" : $ cat z2.f90 program p integer :: i character(3) :: x data (x(i:i), i=1,3) /'a', 'b', 'c'/ print *, x end $ gfortran-8-20180211 z2.f90 -static-libgfortran $ a.out abc $ cat z3.f90 program p integer :: i character(3) :: x data (x(i:i), i=1,3) /3*'a'/ print *, x end $ gfortran-8-20180211 z3.f90 -static-libgfortran $ a.out aaa $ cat z4.f90 program p character(3) :: x data x(1:1), x(2:2), x(3:3) /'a', 'b', 'c'/ print *, x end $ gfortran-8-20180211 z4.f90 -static-libgfortran $ a.out abc
The implied do variants z1, z2, and z3 are now rejected, probably by Steve's recent patch. z4 is fine. Is there anything left, or can this PR be closed?
> The implied do variants z1, z2, and z3 are now rejected, > probably by Steve's recent patch. > > z4 is fine. > > Is there anything left, or can this PR be closed? Confirmed, closing as FIXED.