https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80971
Bug ID: 80971 Summary: [7/8 Regression] ICE with 'if constexpr' in template function Product: gcc Version: 8.0 Status: UNCONFIRMED Keywords: ice-on-valid-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 valid code snippet (compiled with -std=c++1z) triggers an ICE since GCC 7.1.0: ====================================================== struct A { constexpr operator bool() const { return true; } }; template<int> bool foo() { if constexpr (A()) return false; return true; } ====================================================== bug.cc: In function 'bool foo()': bug.cc:8:20: internal compiler error: unexpected expression 'A()' of kind cast_expr if constexpr (A()) ^ 0x6461c7 cxx_eval_constant_expression ../../gcc/gcc/cp/constexpr.c:4592 0x649557 cxx_eval_outermost_constant_expr ../../gcc/gcc/cp/constexpr.c:4652 0x7fca49 finish_if_stmt_cond(tree_node*, tree_node*) ../../gcc/gcc/cp/semantics.c:736 0x74552c cp_parser_selection_statement ../../gcc/gcc/cp/parser.c:11172 0x74552c cp_parser_statement ../../gcc/gcc/cp/parser.c:10583 0x745fbd cp_parser_statement_seq_opt ../../gcc/gcc/cp/parser.c:11054 0x74608f cp_parser_compound_statement ../../gcc/gcc/cp/parser.c:11008 0x760853 cp_parser_function_body ../../gcc/gcc/cp/parser.c:21445 0x760853 cp_parser_ctor_initializer_opt_and_function_body ../../gcc/gcc/cp/parser.c:21483 0x765e61 cp_parser_function_definition_after_declarator ../../gcc/gcc/cp/parser.c:26290 0x74f8bd cp_parser_function_definition_from_specifiers_and_declarator ../../gcc/gcc/cp/parser.c:26202 0x74f8bd cp_parser_init_declarator ../../gcc/gcc/cp/parser.c:19168 0x74fe3a cp_parser_single_declaration ../../gcc/gcc/cp/parser.c:26748 0x76910c cp_parser_template_declaration_after_parameters ../../gcc/gcc/cp/parser.c:26352 0x768d94 cp_parser_explicit_template_declaration ../../gcc/gcc/cp/parser.c:26587 0x768d94 cp_parser_template_declaration_after_export ../../gcc/gcc/cp/parser.c:26606 0x741c79 cp_parser_declaration ../../gcc/gcc/cp/parser.c:12472 0x77753b cp_parser_declaration_seq_opt ../../gcc/gcc/cp/parser.c:12399 0x77781a cp_parser_translation_unit ../../gcc/gcc/cp/parser.c:4364 0x77781a c_parse_file() ../../gcc/gcc/cp/parser.c:38475 Please submit a full bug report, [etc.]