Bug 84218 - ICE in free_expr0, at fortran/expr.c:451
Summary: ICE in free_expr0, at fortran/expr.c:451
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 8.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2018-02-05 17:48 UTC by G. Steinmetz
Modified: 2018-03-05 21:54 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-02-05 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description G. Steinmetz 2018-02-05 17:48:38 UTC
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
Comment 1 Martin Liška 2018-02-05 21:07:47 UTC
Confirmed, I see the ICE for all releases I have (4.5.0+).
Comment 2 Neil Carlson 2018-02-07 21:16:11 UTC
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.
Comment 3 G. Steinmetz 2018-02-14 17:00:34 UTC
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
Comment 4 Harald Anlauf 2018-03-05 21:49:27 UTC
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?
Comment 5 Dominique d'Humieres 2018-03-05 21:54:18 UTC
> 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.