https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95999
Bug ID: 95999 Summary: ICE in tree check: expected integer_cst, have var_decl in get_len, at tree.h:5951 Product: gcc Version: 11.0 Status: UNCONFIRMED Keywords: error-recovery, ice-on-invalid-code Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: haoxintu at gmail dot com CC: webrown.cpp at gmail dot com Target Milestone: --- CC: webrown.cpp at gmail dot com This code, bug.cc, reduced by C-Reduce, makes GCC-trunk ICE. $cat bug.cc int a; enum struct b; template <typename = enum struct b { c = a d } template <> enum struct b { e }; $g++ bug.cc bug.cc:3:42: error: the value of ‘a’ is not usable in a constant expression 3 | template <typename = enum struct b { c = a d } | ^ bug.cc:1:5: note: ‘int a’ is not const 1 | int a; | ^ bug.cc:3:44: error: expected ‘}’ before ‘d’ 3 | template <typename = enum struct b { c = a d } | ~ ^ bug.cc:3:44: error: expected ‘>’ before ‘d’ bug.cc:3:46: error: expected unqualified-id before ‘}’ token 3 | template <typename = enum struct b { c = a d } | ^ bug.cc:3:46: error: expected declaration before ‘}’ token bug.cc:4:29: internal compiler error: tree check: expected integer_cst, have var_decl in get_len, at tree.h:5951 4 | template <> enum struct b { e }; | ^ 0x7c2dcf tree_check_failed(tree_node const*, char const*, int, char const*, ...) ../../gcc/tree.c:9685 0x61582f tree_check(tree_node const*, char const*, int, char const*, tree_code) ../../gcc/tree.h:3557 0x61582f wi::extended_tree<192>::get_len() const ../../gcc/tree.h:5951 0x61582f wi::int_traits<generic_wide_int<wi::extended_tree<192> > >::decompose(long*, unsigned int, generic_wide_int<wi::extended_tree<192> > const&) ../../gcc/wide-int.h:985 0x61582f wide_int_ref_storage<true, false>::wide_int_ref_storage<generic_wide_int<wi::extended_tree<192> > >(generic_wide_int<wi::extended_tree<192> > const&, unsigned int) ../../gcc/wide-int.h:1034 0x61582f generic_wide_int<wide_int_ref_storage<true, false> >::generic_wide_int<generic_wide_int<wi::extended_tree<192> > >(generic_wide_int<wi::extended_tree<192> > const&, unsigned int) ../../gcc/wide-int.h:790 0x61582f wi::binary_traits<generic_wide_int<wi::extended_tree<192> >, int, wi::int_traits<generic_wide_int<wi::extended_tree<192> > >::precision_type, wi::int_traits<int>::precision_type>::result_type wi::add<generic_wide_int<wi::extended_tree<192> >, int>(generic_wide_int<wi::extended_tree<192> > const&, int const&, signop, wi::overflow_type*) ../../gcc/wide-int.h:2467 0x61582f build_enumerator(tree_node*, tree_node*, tree_node*, tree_node*, unsigned int) ../../gcc/cp/decl.c:15857 0x9a2447 cp_parser_enumerator_definition ../../gcc/cp/parser.c:19545 0x9a2447 cp_parser_enumerator_list ../../gcc/cp/parser.c:19474 0x9a2447 cp_parser_enum_specifier ../../gcc/cp/parser.c:19405 0x9a2447 cp_parser_type_specifier ../../gcc/cp/parser.c:17734 0x9a2a02 cp_parser_decl_specifier_seq ../../gcc/cp/parser.c:14410 0x9c8f35 cp_parser_single_declaration ../../gcc/cp/parser.c:29459 0x9ca0f0 cp_parser_explicit_specialization ../../gcc/cp/parser.c:17654 0x9ccac9 cp_parser_declaration ../../gcc/cp/parser.c:13430 0x9cd06a cp_parser_translation_unit ../../gcc/cp/parser.c:4761 0x9cd06a c_parse_file() ../../gcc/cp/parser.c:44043 0xae4dbb c_common_parse_file() ../../gcc/c-family/c-opts.c:1190 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. $g++ --version g++ (GCC) 11.0.0 20200626 (experimental) Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.