https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96162
Bug ID: 96162 Summary: [11 Regression] ICE in discriminator_for_local_entity, at cp/mangle.c:1910 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, test.cc, is an invalid code, makes GCC-trunk ICE. Interestingly, this code does not trigger other released GCC-10 or GCC-9 ICE (confused by earlier errors, bailing out). I guess this is a special regression error-recovery case that is different from others. $cat test.cc #include <iostream> void foo() { for (thread_local int * a ){} } $g++ test.cc test.cc: In function ‘void foo()’: test.cc:3:30: error: expected ‘;’ before ‘)’ token 3 | for (thread_local int * a ){} | ^~ | ; test.cc:3:31: error: expected primary-expression before ‘)’ token 3 | for (thread_local int * a ){} | ^ test.cc:3:30: error: expected ‘;’ before ‘)’ token 3 | for (thread_local int * a ){} | ^~ | ; test.cc: At global scope: test.cc:3:29: internal compiler error: in discriminator_for_local_entity, at cp/mangle.c:1910 3 | for (thread_local int * a ){} | ^ 0x69e943 discriminator_for_local_entity ../../gcc/cp/mangle.c:1910 0x9cdee8 write_local_name ../../gcc/cp/mangle.c:2019 0x9cdee8 write_name ../../gcc/cp/mangle.c:973 0x9d05a7 write_encoding ../../gcc/cp/mangle.c:825 0x9d5981 mangle_decl_string ../../gcc/cp/mangle.c:3858 0x9d5ba6 get_mangled_id ../../gcc/cp/mangle.c:3879 0x9d5ba6 mangle_decl(tree_node*) ../../gcc/cp/mangle.c:3917 0x12fca7d decl_assembler_name(tree_node*) ../../gcc/tree.c:708 0xbf17d9 symbol_table::insert_to_assembler_name_hash(symtab_node*, bool) ../../gcc/symtab.c:174 0xbf193c symbol_table::symtab_initialize_asm_name_hash() ../../gcc/symtab.c:266 0xbf2334 symbol_table::symtab_initialize_asm_name_hash() ../../gcc/symtab.c:1033 0xbf2334 symtab_node::get_for_asmname(tree_node const*) ../../gcc/symtab.c:1021 0xc02e60 handle_alias_pairs ../../gcc/cgraphunit.c:1512 0xc08ccc symbol_table::finalize_compilation_unit() ../../gcc/cgraphunit.c:2962 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++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/home/haoxin/compilers/gcc/build/libexec/gcc/x86_64-pc-linux-gnu/11.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../configure CC=gcc-10 CXX=g++-10 --prefix=/home/haoxin/compilers/gcc/build/ --enable-languages=c,c++ --disable-multilib Thread model: posix Supported LTO compression algorithms: zlib gcc version 11.0.0 20200708 (experimental) (GCC) Thanks, Haoxin