https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101281
Bug ID: 101281 Summary: [11/12 Regression] ICE with -std=f2003/f2008 and assumed-rank array Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: error-recovery, ice-on-invalid-code Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org Target Milestone: --- Created attachment 51094 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51094&action=edit Compile with -std=f2003 or -std=f2008 Found when working on a BIND(C) character testcase. Can probably be reduced. The problem seems to be related to assumed-rank arrays and it only occurs (at least in this testcase) for -std=f2003 and -std=f2008, i.e. it works with -std=-f2008. I did see it with GCC 11 and GCC 12 - but GCC 10 also showed: (null):0: confused by earlier errors, bailing out For some reasons, it does sometimes not crash with 'f951' in the debugger, unless I pass '-quiet' It looks as if some error recovery is failing. In any case: 0x00000000008e6ca6 in gfc_resolve_expr (e=0x270a9f0) at ../../repos/gcc/gcc/fortran/resolve.c:7085 7085 else if (e->symtree != NULL (gdb) p e->symtree $1 = (gfc_symtree *) 0x270a9b0 (gdb) p e->symtree->n.sym $2 = (gfc_symbol *) 0x0 The proc being processed is: (gdb) p gfc_current_ns->proc_name->name $9 = 0x7ffff716f258 "a3ar" Depending how the code is reduced, the ICE is gone. However, I did not try very hard to reduce the code. Stacktrace is: (gdb) p *e $6 = {expr_type = EXPR_VARIABLE, ts = {type = BT_UNKNOWN, and all values are 0 except for 'where' and 'symtree'. ICEs in 0xeb368f crash_signal ../../repos/gcc/gcc/toplev.c:328 0x8e6ca6 gfc_resolve_expr(gfc_expr*) ../../repos/gcc/gcc/fortran/resolve.c:7086 0x8ea58a gfc_resolve_expr(gfc_expr*) ../../repos/gcc/gcc/fortran/resolve.c:7071 0x8ea58a resolve_index_expr ../../repos/gcc/gcc/fortran/resolve.c:12444 0x8ea58a resolve_charlen ../../repos/gcc/gcc/fortran/resolve.c:12497 0x8ee550 resolve_charlen ../../repos/gcc/gcc/fortran/resolve.c:12465 0x8ee550 resolve_types ../../repos/gcc/gcc/fortran/resolve.c:17343