https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84138
Bug ID: 84138 Summary: [8 Regression] ICE folding broken constant Product: gcc Version: 8.0 Status: UNCONFIRMED Keywords: error-recovery, ice-on-invalid-code Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: reichelt at gcc dot gnu.org CC: mpolacek at gcc dot gnu.org Target Milestone: --- The following invalid code snippet triggers an ICE on trunk: ============================== char foo() { const int i = 0 = 0; return 1 ? 0 : (char)i; } ============================== bug.cc: In function 'char foo()': bug.cc:3:21: error: lvalue required as left operand of assignment const int i = 0 = 0; ^ bug.cc:4:24: internal compiler error: tree check: expected class 'type', have 'exceptional' (error_mark) in useless_type_conversion_p, at gimple-expr.c:86 return 1 ? 0 : (char)i; ^ 0x788ca8 tree_class_check_failed(tree_node const*, tree_code_class, char const*, int, char const*) ../../gcc/gcc/tree.c:9375 0x6cb04c tree_class_check(tree_node*, tree_code_class, char const*, int, char const*) ../../gcc/gcc/tree.h:3255 0x6cb04c useless_type_conversion_p(tree_node*, tree_node*) ../../gcc/gcc/gimple-expr.c:86 0x865fb4 cp_fold ../../gcc/gcc/cp/cp-gimplify.c:2359 0x8671cc cp_fold_maybe_rvalue ../../gcc/gcc/cp/cp-gimplify.c:2006 0x865872 cp_fold_maybe_rvalue ../../gcc/gcc/cp/cp-gimplify.c:2137 0x865872 cp_fold ../../gcc/gcc/cp/cp-gimplify.c:2137 0x8671cc cp_fold_maybe_rvalue ../../gcc/gcc/cp/cp-gimplify.c:2006 0x9e2202 maybe_warn_about_returning_address_of_local ../../gcc/gcc/cp/typeck.c:8995 0x9e2202 check_return_expr(tree_node*, bool*) ../../gcc/gcc/cp/typeck.c:9385 0x99cdfe finish_return_stmt(tree_node*) ../../gcc/gcc/cp/semantics.c:890 0x919fa4 cp_parser_jump_statement ../../gcc/gcc/cp/parser.c:12368 0x919fa4 cp_parser_statement ../../gcc/gcc/cp/parser.c:10773 0x91ad20 cp_parser_statement_seq_opt ../../gcc/gcc/cp/parser.c:11218 0x91adf7 cp_parser_compound_statement ../../gcc/gcc/cp/parser.c:11172 0x931580 cp_parser_function_body ../../gcc/gcc/cp/parser.c:21710 0x931580 cp_parser_ctor_initializer_opt_and_function_body ../../gcc/gcc/cp/parser.c:21747 0x931e30 cp_parser_function_definition_after_declarator ../../gcc/gcc/cp/parser.c:26648 0x932b47 cp_parser_function_definition_from_specifiers_and_declarator ../../gcc/gcc/cp/parser.c:26564 0x932b47 cp_parser_init_declarator ../../gcc/gcc/cp/parser.c:19436 Please submit a full bug report, [etc.] The regression was introduced between 2017-07-31 and 2017-08-09. Marek, I suspect that your patch > 2017-08-08 Marek Polacek <pola...@redhat.com> > > PR c++/81607 > * cp-gimplify.c (cp_fold): If folding exposed a branch of > a COND_EXPR, convert it to the original type of the COND_EXPR, if > they differ. might be responsible. Would you mind having a look?