https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96441
Bug ID: 96441 Summary: ICE in tree check: expected integer_cst, have cond_expr in get_len, at tree.h:5954 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 Target Milestone: --- Hi, all. This code, reduced by C-Vise, makes GCC-trunk ICE and makes released GCC versions "confused by early errors". Input: //small.cc enum struct a : int; template <typename = enum class a { b = 0 ? : throw}> class A {}; template <> enum struct a {c}; Command: g++ small.cc Output: small.cc:2:47: error: expression ‘<throw-expression>’ is not a constant expression 2 | template <typename = enum class a { b = 0 ? : throw}> class A {}; | ^~~~~ small.cc:3:28: internal compiler error: tree check: expected integer_cst, have cond_expr in get_len, at tree.h:5954 3 | template <> enum struct a {c}; | ^ 0x7c7fd7 tree_check_failed(tree_node const*, char const*, int, char const*, ...) ../../gcc/tree.c:9687 0x616fed tree_check(tree_node const*, char const*, int, char const*, tree_code) ../../gcc/tree.h:3559 0x616fed wi::extended_tree<192>::get_len() const ../../gcc/tree.h:5954 0x616fed 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 0x616fed 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 0x616fed 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 0x616fed 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 0x616fed build_enumerator(tree_node*, tree_node*, tree_node*, tree_node*, unsigned int) ../../gcc/cp/decl.c:15857 0x9aafec cp_parser_enumerator_definition ../../gcc/cp/parser.c:19585 0x9aafec cp_parser_enumerator_list ../../gcc/cp/parser.c:19514 0x9aafec cp_parser_enum_specifier ../../gcc/cp/parser.c:19444 0x9aafec cp_parser_type_specifier ../../gcc/cp/parser.c:17769 0x9ab50e cp_parser_decl_specifier_seq ../../gcc/cp/parser.c:14436 0x9d2fe5 cp_parser_single_declaration ../../gcc/cp/parser.c:29499 0x9d4300 cp_parser_explicit_specialization ../../gcc/cp/parser.c:17689 0x9d776d cp_parser_declaration ../../gcc/cp/parser.c:13456 0x9d7d2b cp_parser_translation_unit ../../gcc/cp/parser.c:4793 0x9d7d2b c_parse_file() ../../gcc/cp/parser.c:44081 0xaf2e9d c_common_parse_file() ../../gcc/c-family/c-opts.c:1188 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. My gcc version is Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/home/haoxin/corpus-compilers/gcc-trunk/gcc-master/build/libexec/gcc/x86_64-pc-linux-gnu/11.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../configure --prefix=/home/haoxin/corpus-compilers/gcc-trunk/gcc-master/build/ --enable-languages=c,c++ CC=gcc CXX=g++ Thread model: posix Supported LTO compression algorithms: zlib gcc version 11.0.0 20200801 (experimental) (GCC) Thanks, Haoxin