https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90393
Bug ID: 90393 Summary: [9 Regression] ICE in return statement with a conditional operator, one of the second and third arguments is throw, and the other is a const variable of a class with a nontrivial copy constructor. Product: gcc Version: 9.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jostaberry.jam at gmail dot com Target Milestone: --- This ICE occurred if the return statement is a conditional operator, one of the second and third operands is throw, and the other is a const variable of a class with a non-trivial copy constructor. =========================== code: prog.cc =========================== struct S { S() = default; S(const S&) {} }; S f() { const S m; return true ? m : throw 0; } int main() {} =========================== end code =========================== =========================== command ============================ $ g++ ./prog.cpp =========================== end command ======================== =========================== compiler output =========================== prog.cc: In function 'S f()': prog.cc:8:29: internal compiler error: in ocp_convert, at cp/cvt.c:766 8 | return true ? m : throw 0; | ^ 0x588de1 ocp_convert(tree_node*, tree_node*, int, int, int) ../../gcc-9.1.0/gcc/cp/cvt.c:766 0x7195b2 check_return_expr(tree_node*, bool*) ../../gcc-9.1.0/gcc/cp/typeck.c:9799 0x6e87ff finish_return_stmt(tree_node*) ../../gcc-9.1.0/gcc/cp/semantics.c:894 0x68dd2d cp_parser_jump_statement ../../gcc-9.1.0/gcc/cp/parser.c:12919 0x68dd2d cp_parser_statement ../../gcc-9.1.0/gcc/cp/parser.c:11191 0x68e398 cp_parser_statement_seq_opt ../../gcc-9.1.0/gcc/cp/parser.c:11657 0x68e450 cp_parser_compound_statement ../../gcc-9.1.0/gcc/cp/parser.c:11611 0x6a49d0 cp_parser_function_body ../../gcc-9.1.0/gcc/cp/parser.c:22660 0x6a49d0 cp_parser_ctor_initializer_opt_and_function_body ../../gcc-9.1.0/gcc/cp/parser.c:22711 0x6a51b1 cp_parser_function_definition_after_declarator ../../gcc-9.1.0/gcc/cp/parser.c:27802 0x6a5e7b cp_parser_function_definition_from_specifiers_and_declarator ../../gcc-9.1.0/gcc/cp/parser.c:27718 0x6a5e7b cp_parser_init_declarator ../../gcc-9.1.0/gcc/cp/parser.c:20297 0x68b02e cp_parser_simple_declaration ../../gcc-9.1.0/gcc/cp/parser.c:13541 0x6ab1a0 cp_parser_declaration ../../gcc-9.1.0/gcc/cp/parser.c:13238 0x6ab8c9 cp_parser_translation_unit ../../gcc-9.1.0/gcc/cp/parser.c:4701 0x6ab8c9 c_parse_file() ../../gcc-9.1.0/gcc/cp/parser.c:41181 0x76605b c_common_parse_file() ../../gcc-9.1.0/gcc/c-family/c-opts.c:1156 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. =========================== end compiler output =======================