Created attachment 44210 [details] source (http://nn-online.org/code/strings/strings-1.3.tar.gz) Linux kernel 3.10 CentOS 7.4 gfortran --version GNU Fortran (GCC) 8.1.0 tar xzf strings-1.3.tar.gz cd strings-1.3 gfortran -Wall -Wextra -c m_strings.F95 f951: internal compiler error: gfc_trans_select(): Bad type for case expr. 0x60128f gfc_internal_error(char const*, ...) ../../gcc-8.1.0/gcc/fortran/error.c:1358 0x70fe59 gfc_trans_select(gfc_code*) ../../gcc-8.1.0/gcc/fortran/trans-stmt.c:3346 0x6a2ef7 trans_code ../../gcc-8.1.0/gcc/fortran/trans.c:1940 0x6c92cb gfc_generate_function_code(gfc_namespace*) ../../gcc-8.1.0/gcc/fortran/trans-decl.c:6507 0x6a6879 gfc_generate_module_code(gfc_namespace*) ../../gcc-8.1.0/gcc/fortran/trans.c:2222 0x659f4b translate_all_program_units ../../gcc-8.1.0/gcc/fortran/parse.c:6108 0x659f4b gfc_parse_file() ../../gcc-8.1.0/gcc/fortran/parse.c:6324 0x6a02ef gfc_be_parse_file ../../gcc-8.1.0/gcc/fortran/f95-lang.c:204 REM : well compiled with GCC 6.4.0 and 7.1.2
This is a 7000 line piece of code. Please submit a reduced testcase.
Created attachment 44225 [details] reduced testcase
Nice reduction!-) The ICE appeared between revisions r258235 (2018-03-04, OK) and r258362 (2018-03-08, ICE) and the commit has been back ported to the GCC6 and GCC7 branches. (lldb) p code->expr1->ts.type (bt) $0 = BT_UNKNOWN (lldb) bt * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 * frame #0: 0x00000001001707f0 f951`gfc_trans_select(code=0x0000000143006230) at trans-stmt.c:3310 frame #1: 0x00000001000e9748 f951`::trans_code(code=0x0000000143006230, cond=0x0000000000000000) at trans.c:1940 frame #2: 0x0000000100119683 f951`gfc_generate_function_code(ns=<unavailable>) at trans-decl.c:6514 frame #3: 0x00000001000ee1d2 f951`gfc_generate_module_code(ns=0x0000000145003000) at trans.c:2222 frame #4: 0x000000010009ad2c f951`gfc_parse_file() at parse.c:6108 frame #5: 0x000000010009acc3 f951`gfc_parse_file() frame #6: 0x00000001000e648c f951`::gfc_be_parse_file() at f95-lang.c:204 frame #7: 0x0000000100c4667a f951`::compile_file() at toplev.c:455 frame #8: 0x00000001012a6c7b f951`toplev::main(int, char**) at toplev.c:2133 frame #9: 0x00000001012a87be f951`main(argc=2, argv=0x00007ffeefbff250) at main.c:39
On Sun, Jun 03, 2018 at 10:02:35AM +0000, dominiq at lps dot ens.fr wrote: > > Nice reduction!-) > > The ICE appeared between revisions r258235 (2018-03-04, OK) and r258362 > (2018-03-08, ICE) and the commit has been back ported to the GCC6 and GCC7 > branches. > There are 3 commits to gcc/fortran in that range. I reverted what would be the obvious one that might cause a problem and the ICE still occurs. The ICE disappears if uppercase_c and uppercase_s are moved up in the source code to a location that comes before any reference to the generic uppercase.
> There are 3 commits to gcc/fortran in that range. I > reverted what would be the obvious one that might > cause a problem and the ICE still occurs. Was it r258347? > The ICE disappears if uppercase_c and uppercase_s are > moved up in the source code to a location that comes > before any reference to the generic uppercase. This rings some bells, but I am unable to remember for which PR this happened.
On Sun, Jun 03, 2018 at 05:05:42PM +0000, dominiq at lps dot ens.fr wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85996 > > --- Comment #5 from Dominique d'Humieres <dominiq at lps dot ens.fr> --- > > There are 3 commits to gcc/fortran in that range. I > > reverted what would be the obvious one that might > > cause a problem and the ICE still occurs. > > Was it r258347? > Whoops. Reverted in the wrong tree. Appears to be related to 258347.
Could be related to pr85138.
(In reply to Dominique d'Humieres from comment #7) > Could be related to pr85138. Yes, it is related if not the same. I have a patch that fixes both PRs and passes regression testing.
Author: kargl Date: Sat Jun 9 15:47:40 2018 New Revision: 261362 URL: https://gcc.gnu.org/viewcvs?rev=261362&root=gcc&view=rev Log: 2018-06-09 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/85138 PR fortran/85996 PR fortran/86051 * decl.c (gfc_match_char_spec): Use private namespace in attempt to reduce a charlen to a constant. 2018-06-09 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/85138 PR fortran/85996 PR fortran/86051 * gfortran.dg/pr85138_1.f90: New test. * gfortran.dg/pr85138_2.f90: Ditto. * gfortran.dg/pr85996.f90: Ditto. Added: trunk/gcc/testsuite/gfortran.dg/pr85138_1.f90 trunk/gcc/testsuite/gfortran.dg/pr85138_2.f90 trunk/gcc/testsuite/gfortran.dg/pr85996.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/decl.c trunk/gcc/testsuite/ChangeLog
Author: kargl Date: Sat Jun 9 18:09:00 2018 New Revision: 261370 URL: https://gcc.gnu.org/viewcvs?rev=261370&root=gcc&view=rev Log: 2018-06-09 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/85138 PR fortran/85996 PR fortran/86051 * decl.c (gfc_match_char_spec): Use private namespace in attempt to reduce a charlen to a constant. 2018-06-09 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/85138 PR fortran/85996 PR fortran/86051 * gfortran.dg/pr85138_1.f90: New test. * gfortran.dg/pr85138_2.f90: Ditto. * gfortran.dg/pr85996.f90: Ditto. Added: branches/gcc-8-branch/gcc/testsuite/gfortran.dg/pr85138_1.f90 branches/gcc-8-branch/gcc/testsuite/gfortran.dg/pr85138_2.f90 branches/gcc-8-branch/gcc/testsuite/gfortran.dg/pr85996.f90 Modified: branches/gcc-8-branch/gcc/fortran/ChangeLog branches/gcc-8-branch/gcc/fortran/decl.c branches/gcc-8-branch/gcc/testsuite/ChangeLog
Author: kargl Date: Sat Jun 9 18:29:40 2018 New Revision: 261371 URL: https://gcc.gnu.org/viewcvs?rev=261371&root=gcc&view=rev Log: 2018-06-09 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/85138 PR fortran/85996 PR fortran/86051 * decl.c (gfc_match_char_spec): Use private namespace in attempt to reduce a charlen to a constant. 2018-06-09 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/85138 PR fortran/85996 PR fortran/86051 * gfortran.dg/pr85138_1.f90: New test. * gfortran.dg/pr85138_2.f90: Ditto. * gfortran.dg/pr85996.f90: Ditto. Added: branches/gcc-7-branch/gcc/testsuite/gfortran.dg/pr85138_1.f90 branches/gcc-7-branch/gcc/testsuite/gfortran.dg/pr85138_2.f90 branches/gcc-7-branch/gcc/testsuite/gfortran.dg/pr85996.f90 Modified: branches/gcc-7-branch/gcc/fortran/ChangeLog branches/gcc-7-branch/gcc/fortran/decl.c branches/gcc-7-branch/gcc/testsuite/ChangeLog
Author: kargl Date: Sat Jun 9 18:35:58 2018 New Revision: 261372 URL: https://gcc.gnu.org/viewcvs?rev=261372&root=gcc&view=rev Log: 2018-06-09 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/85138 PR fortran/85996 PR fortran/86051 * decl.c (gfc_match_char_spec): Use private namespace in attempt to reduce a charlen to a constant. 2018-06-09 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/85138 PR fortran/85996 PR fortran/86051 * gfortran.dg/pr85138_1.f90: New test. * gfortran.dg/pr85138_2.f90: Ditto. * gfortran.dg/pr85996.f90: Ditto. Added: branches/gcc-6-branch/gcc/testsuite/gfortran.dg/pr85138_1.f90 branches/gcc-6-branch/gcc/testsuite/gfortran.dg/pr85138_2.f90 branches/gcc-6-branch/gcc/testsuite/gfortran.dg/pr85996.f90 Modified: branches/gcc-6-branch/gcc/fortran/ChangeLog branches/gcc-6-branch/gcc/fortran/decl.c branches/gcc-6-branch/gcc/testsuite/ChangeLog
Fixed on trunk and 6, 7, and 8 branches.