https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127535
Bug ID: 127535
Summary: [GIMPLE FE] statements built from error_mark_node /
non-register operands are handed to
gimple_build_assign, the operand scanner and the
verifier
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: error-recovery, ice-on-invalid-code
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: captainnemo9292 at gmail dot com
Target Milestone: ---
Target: x86_64-linux-gnu
c_parser_gimple_statement does not bail out when an operand expression
fails to parse (or is not a valid GIMPLE operand), so the erroneous tree is
turned into a gimple statement and a later consumer ICEs.
Missing left-hand side:
_Complex float a;
void __GIMPLE b() {
= __imag a;
}
$ gcc -fgimple -c t.c
t.c:3:3: error: expected expression before '=' token
t.c:4:1: internal compiler error: tree check: expected class 'type', have
'exceptional' (error_mark) in useless_type_conversion_p, at gimple-expr.cc:85
verify_gimple_in_seq <- c_parser_parse_gimple_body
https://godbolt.org/z/ax4vMq6f7
void __GIMPLE a() { = &42; }
internal compiler error: in extract_ops_from_tree, at gimple-expr.cc:556
gimple_build_assign <- c_parser_parse_gimple_body
https://godbolt.org/z/7zc3Kdc66
Unterminated / invalid __MEM operand:
void __GIMPLE (ssa) a(char *b) { char c; __BB(2): c = __MEM <char> (b + ; }
-O2: internal compiler error: in get_expr_operands, at
tree-ssa-operands.cc:943 (get_tmr_operands)
https://godbolt.org/z/xhW3MWeaY
void __GIMPLE (ssa) a(char *b) { char c; __BB(2): c = __MEM <char> ((int) b);
}
t.c:5:1: error: invalid offset operand in 'mem_ref'
internal compiler error: Segmentation fault in dump_generic_node <-
debug_generic_stmt <- verify_gimple_in_cfg
(the crash is while printing the statement for the diagnostic)
https://godbolt.org/z/Ex9657ebK
Non-register operand in a GIMPLE_COND in an SSA body:
int a;
void __GIMPLE (ssa) b() {
__BB(2):
if (a) goto __BB3; else goto __BB4;
__BB(3):
__BB(4):
}
internal compiler error: in as_a, at is-a.h:255
operands_scanner::finalize_ssa_uses <- build_ssa_operands <-
update_stmt_operands
(a memory load needs a vuse, and a gcond cannot carry one)
https://godbolt.org/z/eYsov47Ms
Empty switch:
void __GIMPLE a() { int b; switch (b) { } }
internal compiler error: in gimple_build_switch_nlabels, at gimple.cc:834
https://godbolt.org/z/j6snoYKKq
gcc trunk 17.0.0 20260920.