https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89958
Bug ID: 89958 Summary: ICE and duplicate diagnostic with invalid return value Product: gcc Version: 9.0 Status: UNCONFIRMED Keywords: diagnostic, 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 Target Milestone: --- The following invalid code snippet triggers an ICE since GCC 6.1.0, killing the diagnostic in mid-sentence. In addition, the first part of the diagnostic is emitted twice: ============================= struct A; constexpr auto foo(A* p) { return *p; } ============================= bug.cc: In function 'constexpr auto foo(A*)': bug.cc:5:11: error: invalid use of incomplete type 'struct A' 5 | return *p; | ^ bug.cc:1:8: note: forward declaration of 'struct A' 1 | struct A; | ^ bug.cc:5:10: error: invalid use of incomplete type 'struct A' 5 | return *p; | ^~ bug.cc:1:8: note: forward declaration of 'struct A' 1 | struct A; | ^ bug.cc:3:16: error: invalid return type 'A' of 'constexpr' function 'constexpr auto foo(A*)' 3 | constexpr auto foo(A* p) | ^~~ bug.cc:1:8: note: 'A' is not literal because: 1 | struct A; | ^ bug.cc:6:1: internal compiler error: Segmentation fault 6 | } | ^ 0xf8203f crash_signal ../../gcc/gcc/toplev.c:326 0x8d0333 tree_check(tree_node*, char const*, int, char const*, tree_code) ../../gcc/gcc/tree.h:3175 0x8d0333 explain_non_literal_class(tree_node*) ../../gcc/gcc/cp/class.c:5525 0x8d91f0 is_valid_constexpr_fn(tree_node*, bool) ../../gcc/gcc/cp/constexpr.c:239 0x8e8c82 register_constexpr_fundef(tree_node*, tree_node*) ../../gcc/gcc/cp/constexpr.c:871 0x92e967 maybe_save_function_definition ../../gcc/gcc/cp/decl.c:15949 0x92e967 finish_function(bool) ../../gcc/gcc/cp/decl.c:16096 0x9cd454 cp_parser_function_definition_after_declarator ../../gcc/gcc/cp/parser.c:27803 0x9ce199 cp_parser_function_definition_from_specifiers_and_declarator ../../gcc/gcc/cp/parser.c:27716 0x9ce199 cp_parser_init_declarator ../../gcc/gcc/cp/parser.c:20295 0x9b049e cp_parser_simple_declaration ../../gcc/gcc/cp/parser.c:13539 0x9d41c0 cp_parser_declaration ../../gcc/gcc/cp/parser.c:13236 0x9d493c cp_parser_translation_unit ../../gcc/gcc/cp/parser.c:4698 0x9d493c c_parse_file() ../../gcc/gcc/cp/parser.c:41180 0xadae9b c_common_parse_file() ../../gcc/gcc/c-family/c-opts.c:1156 Please submit a full bug report, [etc.]