With a missing end apostrophe : $ cat z1.f90 program p character(len=2, kind=4) :: a = 'aa', b = 'bb end $ gfortran-6 -g z1.f90 z1.f90:2:46: character(len=2, kind=4) :: a = 'aa', b = 'bb 1 Error: Unterminated character constant beginning at (1) f951: internal compiler error: gfc_is_constant_expr(): Unknown expression type For some other compile options, error message may depend on $LANG etc.
No ICE if "kind=4" is changed to "kind=1" : $ cat z2.f90 program p character(len=2, kind=1) :: a = 'aa', b = 'bb end $ gfortran-6 -g z2.f90 z2.f90:2:46: character(len=2, kind=1) :: a = 'aa', b = 'bb 1 Error: Unterminated character constant beginning at (1)
Confirmed from 4.4 up to trunk (6.0), except 4.8.5 and 4.8.4 (r217778). Note that I don't see any ICE for character(len=2, kind=4) :: a = 'aa
Index: expr.c =================================================================== --- expr.c (revision 237945) +++ expr.c (working copy) @@ -970,8 +970,14 @@ gfc_is_constant_expr (gfc_expr *e) default: - gfc_internal_error ("gfc_is_constant_expr(): Unknown expression type"); - return 0; + { + int e, w; + gfc_get_errors (&w, &e); + if (e < 1) + gfc_internal_error ("gfc_is_constant_expr(): Unknown " + "expression type"); + return 0; + } } }
Fixed with r238822.
The ICE is gone for several constellations, but not for all. $ gfortran-7-20160821 -mavx z1.f90 z1.f90:2:46: character(len=2, kind=4) :: a = 'aa', b = 'bb 1 Error: Unterminated character constant beginning at (1) f951: internal compiler error: Segmentation fault 0xc1b63f crash_signal ../../gcc/toplev.c:335 0x688b02 gfc_is_constant_expr(gfc_expr*) ../../gcc/fortran/expr.c:899 0x688c1b gfc_is_constant_expr(gfc_expr*) ../../gcc/fortran/expr.c:902 0x6f13ba resolve_fl_procedure ../../gcc/fortran/resolve.c:11618 0x6f13ba resolve_symbol ../../gcc/fortran/resolve.c:14257 0x7098ab do_traverse_symtree ../../gcc/fortran/symbol.c:3930 0x6f319a resolve_types ../../gcc/fortran/resolve.c:15482 0x6eee5c gfc_resolve(gfc_namespace*) ../../gcc/fortran/resolve.c:15593 0x6da18a resolve_all_program_units ../../gcc/fortran/parse.c:5855 0x6da18a gfc_parse_file() ../../gcc/fortran/parse.c:6107 0x71c602 gfc_be_parse_file ../../gcc/fortran/f95-lang.c:198
(In reply to Gerhard Steinmetz from comment #5) > The ICE is gone for several constellations, but not for all. > > > $ gfortran-7-20160821 -mavx z1.f90 > z1.f90:2:46: > > character(len=2, kind=4) :: a = 'aa', b = 'bb > 1 > Error: Unterminated character constant beginning at (1) > f951: internal compiler error: Segmentation fault > 0xc1b63f crash_signal > ../../gcc/toplev.c:335 > 0x688b02 gfc_is_constant_expr(gfc_expr*) > ../../gcc/fortran/expr.c:899 Works for me. % gfc7 -o z a.f90 a.f90:2:46: character(len=2, kind=1) :: a = 'aa', b = 'bb 1 Error: Unterminated character constant beginning at (1) % gfc7 -v |& grep version gcc version 7.0.0 20160822 (experimental) (GCC)
> Works for me. You need -mavx.
(In reply to Dominique d'Humieres from comment #7) > > Works for me. > > You need -mavx. Like I said. Works for me. gfc7 -c -mavx a.f90 a.f90:2:46: character(len=2, kind=1) :: a = 'aa', b = 'bb 1 Error: Unterminated character constant beginning at (1) There is no ICE.
> Like I said. Works for me. How many times did you try? It worked for me the first time, but then I tried -mavx -m32 and got an ICE, then I got the same ICE with -mavx only. Another instance of non-deterministic error recovery?
(In reply to Dominique d'Humieres from comment #9) > > Like I said. Works for me. > > How many times did you try? It worked for me the first time, but then I > tried -mavx -m32 and got an ICE, then I got the same ICE with -mavx only. > Another instance of non-deterministic error recovery? Is this enough times? #! /bin/csh foreach i (0 1 2 3 4 5 6 7 8 9) foreach j (0 1 2 3 4 5 6 7 8 9) gfc7 -c a.f90 |& tee sgk.log gfc7 -c -mavx a.f90 |& tee sgk.log gfc7 -c -m32 a.f90 |& tee sgk.log gfc7 -c -O a.f90 |& tee sgk.log gfc7 -c -O -mavx a.f90 |& tee sgk.log gfc7 -c -O -m32 a.f90 |& tee sgk.log end end grep -i internal sgk.log No ICE.
And with "kind=4" instead of "kind=1", i.e. with testfile z1.f90 ? for n in `seq 1 1000` do gfortran-7-20160821 -O2 -mavx -c z1.f90 done > list 2>&1 grep 'internal compiler' list | wc 946 5676 47300 I can also confirm that ICEs are gone for z2.f90 ("kind=1").
(In reply to Gerhard Steinmetz from comment #11) > And with "kind=4" instead of "kind=1", i.e. with testfile z1.f90 ? > > > for n in `seq 1 1000` > do > gfortran-7-20160821 -O2 -mavx -c z1.f90 > done > list 2>&1 > > grep 'internal compiler' list | wc > 946 5676 47300 > > > I can also confirm that ICEs are gone for z2.f90 ("kind=1"). Ugh. I was testing apparently a kind=1 version. The problem is that gfortran is inserting __convert_s1_s4 to convert to the same kind, which of course fails. This un-regression-tested patch covers up the ICE, but it is perhaps not the correct fix. Fortunately, I don't use kind=4 character types, so I don't have a dog in this fight. Index: primary.c =================================================================== --- primary.c (revision 239661) +++ primary.c (working copy) @@ -1105,8 +1105,8 @@ got_delim: if (ret == -2) { gfc_current_locus = start_locus; - gfc_error ("Unterminated character constant beginning at %C"); - return MATCH_ERROR; + gfc_error_now ("Unterminated character constant beginning at %C"); + return MATCH_NO; } length++;
(In reply to kargl from comment #12) > (In reply to Gerhard Steinmetz from comment #11) > > And with "kind=4" instead of "kind=1", i.e. with testfile z1.f90 ? > > > > > > for n in `seq 1 1000` > > do > > gfortran-7-20160821 -O2 -mavx -c z1.f90 > > done > list 2>&1 > > > > grep 'internal compiler' list | wc > > 946 5676 47300 > > > > > > I can also confirm that ICEs are gone for z2.f90 ("kind=1"). > > Ugh. I was testing apparently a kind=1 version. The problem > is that gfortran is inserting __convert_s1_s4 to convert to > the same kind, which of course fails. This un-regression-tested > patch covers up the ICE, but it is perhaps not the correct fix. > Fortunately, I don't use kind=4 character types, so I don't have > a dog in this fight. > This might have been fixed by Janus patch: 2016-12-04 Janus Weil <janus@gcc.gnu.org> PR fortran/78618 * intrinsic.c (gfc_convert_type_warn): Do not set the full typespec for the conversion symbol, but only type and kind. Set the full typespec for the expression. (gfc_convert_chartype): Ditto. Gerhard can re-do your testing. I seem to have good luck with FreeBSD in testing this.
(In reply to kargl from comment #13) > Gerhard can re-do your testing. I seem to have good luck with FreeBSD > in testing this. On Ubuntu 16.10, I don't see any ICE with current trunk either, using the method from comment #11. But then, I don't even see ICEs with 5.4.1 or 6.2.0. I only see some with 4.9. From my side, this can be closed.
Confirmed, this ICE is now completely gone on my environment.
(In reply to Gerhard Steinmetz from comment #15) > Confirmed, this ICE is now completely gone on my environment. Great! Closing.