https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85228

            Bug ID: 85228
           Summary: [8 Regression] ICE with constexpr lambda in template
           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 on trunk:

=======================================
template<int> struct A
{
  enum E { e = []{ return 0; }() };
};

template class A<0>;
=======================================

bug.cc:6:16: internal compiler error: Segmentation fault
 template class A<0>;
                ^~~~
0xebd2ff crash_signal
        ../../gcc/gcc/toplev.c:325
0x990601 tree_check(tree_node*, char const*, int, char const*, tree_code)
        ../../gcc/gcc/tree.h:3134
0x990601 bt_instantiate_type_proc
        ../../gcc/gcc/cp/pt.c:22826
0x8fe237 binding_table_foreach(binding_table_s*, void (*)(binding_entry_s*,
void*), void*)
        ../../gcc/gcc/cp/name-lookup.c:1936
0x990423 do_type_instantiation(tree_node*, tree_node*, int)
        ../../gcc/gcc/cp/pt.c:22970
0x94290f cp_parser_explicit_instantiation
        ../../gcc/gcc/cp/parser.c:16543
0x949361 cp_parser_declaration
        ../../gcc/gcc/cp/parser.c:12724
0x9496b1 cp_parser_declaration_seq_opt
        ../../gcc/gcc/cp/parser.c:12648
0x9499a4 cp_parser_translation_unit
        ../../gcc/gcc/cp/parser.c:4563
0x9499a4 c_parse_file()
        ../../gcc/gcc/cp/parser.c:39016
0xa49636 c_common_parse_file()
        ../../gcc/gcc/c-family/c-opts.c:1132
Please submit a full bug report, [etc.]

The regression was introduced between 2017-08-19 and 2017-09-02.
Before, the code was wrongly rejected:

bug.cc:3:32: error: expression '<lambda>' is not a constant expression
   enum E { e = []{ return 0; }() };
                                ^

Reply via email to