https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115469
Bug ID: 115469 Summary: ICE :tree check expected class 'type', have 'exceptional' (error_mark) in poplevel_named_label_1, at cpdecl.cc579 Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: iamanonymous.cs at gmail dot com Target Milestone: --- Target: x86_64 ******************************************************************************* I encountered an internal compiler error (ICE) while compiling the following code snippet using GCC trunk with the provided compilation options. The ICE occurred in poplevel_named_label_1 at cp/decl.cc:579. The issue can also be reproduced on Compiler Explorer. Please let me know if you need any further information to resolve this issue. ******************************************************************************* OS and Platform: # uname -a Linux ubuntu 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux ******************************************************************************* # g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/root/gdbtest/gcc/gcc-15/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /root/gdbtest/gcc/obj/../gcc/configure --prefix=/root/gdbtest/gcc/gcc-15 --enable-languages=c,c++,fortran,go --disable-multilib Thread model: posix Supported LTO compression algorithms: zlib gcc version 15.0.0 20240509 (experimental) (GCC) ******************************************************************************* Program: # cat 1.ii int fn1() { int **c; b = &&c; goto * 0} ******************************************************************************* Command Lines: # g++ 1.ii -O3 -Wall -Wextra -std=c11 -pedantic -fsanitize=undefined -fstack-protector-all -D_FORTIFY_SOURCE=2 -freport-bug -o -c 1.o cc1plus: warning: command-line option ‘-std=c11’ is valid for C/ObjC but not for C++ 1.ii: In function ‘int fn1()’: 1.ii:1:22: error: ‘b’ was not declared in this scope 1 | int fn1() { int **c; b = &&c; goto * 0} | ^ 1.ii:1:28: warning: taking the address of a label is non-standard [-Wpedantic] 1 | int fn1() { int **c; b = &&c; goto * 0} | ^ 1.ii:1:33: warning: ISO C++ forbids computed gotos [-Wpedantic] 1 | int fn1() { int **c; b = &&c; goto * 0} | ^~~~ 1.ii:1:41: error: expected ‘;’ before ‘}’ token 1 | int fn1() { int **c; b = &&c; goto * 0} | ^ | ; 1.ii:1:41: internal compiler error: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in poplevel_named_label_1, at cp/decl.cc:579 0x99e778 tree_class_check_failed(tree_node const*, tree_code_class, char const*, int, char const*) /root/gdbtest/gcc/obj/../gcc/gcc/tree.cc:9045 0x7d7cca tree_class_check(tree_node*, tree_code_class, char const*, int, char const*) /root/gdbtest/gcc/obj/../gcc/gcc/tree.h:3779 0x7d7cca poplevel_named_label_1(named_label_entry**, cp_binding_level*) /root/gdbtest/gcc/obj/../gcc/gcc/cp/decl.cc:579 0xb735f8 void hash_table<named_label_hash, false, xcallocator>::traverse_noresize<cp_binding_level*, &(poplevel_named_label_1(named_label_entry**, cp_binding_level*))>(cp_binding_level*) /root/gdbtest/gcc/obj/../gcc/gcc/cp/decl.cc:650 0xb735f8 void hash_table<named_label_hash, false, xcallocator>::traverse<cp_binding_level*, &(poplevel_named_label_1(named_label_entry**, cp_binding_level*))>(cp_binding_level*) /root/gdbtest/gcc/obj/../gcc/gcc/hash-table.h:1194 0xb735f8 poplevel(int, int, int) /root/gdbtest/gcc/obj/../gcc/gcc/cp/decl.cc:650 0xd04842 do_poplevel(tree_node*) /root/gdbtest/gcc/obj/../gcc/gcc/cp/semantics.cc:651 0xd07599 finish_compound_stmt(tree_node*) /root/gdbtest/gcc/obj/../gcc/gcc/cp/semantics.cc:1996 0xc59a4c cp_parser_compound_statement /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:13287 0xc7ccd5 cp_parser_function_body /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:26072 0xc7ccd5 cp_parser_ctor_initializer_opt_and_function_body /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:26123 0xc8241e cp_parser_function_definition_after_declarator /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:32903 0xc835be cp_parser_function_definition_from_specifiers_and_declarator /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:32820 0xc835be cp_parser_init_declarator /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:23451 0xc5668f cp_parser_simple_declaration /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:15958 0xc8ffea cp_parser_declaration /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:15631 0xc90fea cp_parser_toplevel_declaration /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:15652 0xc90fea cp_parser_translation_unit /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:5284 0xc90fea c_parse_file() /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:51440 0xddf371 c_common_parse_file() /root/gdbtest/gcc/obj/../gcc/gcc/c-family/c-opts.cc:1311 Please submit a full bug report, with preprocessed source. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. Preprocessed source stored into /tmp/cc5sFDUL.out file, please attach this to your bugreport. ******************************************************************************* #cat /tmp/cc5sFDUL.out // Target: x86_64-pc-linux-gnu // Configured with: /root/gdbtest/gcc/obj/../gcc/configure --prefix=/root/gdbtest/gcc/gcc-15 --enable-languages=c,c++,fortran,go --disable-multilib // Thread model: posix // Supported LTO compression algorithms: zlib // gcc version 15.0.0 20240509 (experimental) (GCC) // // -fpreprocessed: warning: command-line option ‘-std=c11’ is valid for C/ObjC but not for C++ // 1.ii: In function ‘int fn1()’: // 1.ii:1:22: error: ‘b’ was not declared in this scope // 1 | int fn1() { int **c; b = &&c; goto * 0} // | ^ // 1.ii:1:28: warning: taking the address of a label is non-standard [-Wpedantic] // 1 | int fn1() { int **c; b = &&c; goto * 0} // | ^ // 1.ii:1:33: warning: ISO C++ forbids computed gotos [-Wpedantic] // 1 | int fn1() { int **c; b = &&c; goto * 0} // | ^~~~ // 1.ii:1:41: error: expected ‘;’ before ‘}’ token // 1 | int fn1() { int **c; b = &&c; goto * 0} // | ^ // | ; // 1.ii:1:41: internal compiler error: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in poplevel_named_label_1, at cp/decl.cc:579 // 0x99e778 tree_class_check_failed(tree_node const*, tree_code_class, char const*, int, char const*) // /root/gdbtest/gcc/obj/../gcc/gcc/tree.cc:9045 // 0x7d7cca tree_class_check(tree_node*, tree_code_class, char const*, int, char const*) // /root/gdbtest/gcc/obj/../gcc/gcc/tree.h:3779 // 0x7d7cca poplevel_named_label_1(named_label_entry**, cp_binding_level*) // /root/gdbtest/gcc/obj/../gcc/gcc/cp/decl.cc:579 // 0xb735f8 void hash_table<named_label_hash, false, xcallocator>::traverse_noresize<cp_binding_level*, &(poplevel_named_label_1(named_label_entry**, cp_binding_level*))>(cp_binding_level*) // /root/gdbtest/gcc/obj/../gcc/gcc/cp/decl.cc:650 // 0xb735f8 void hash_table<named_label_hash, false, xcallocator>::traverse<cp_binding_level*, &(poplevel_named_label_1(named_label_entry**, cp_binding_level*))>(cp_binding_level*) // /root/gdbtest/gcc/obj/../gcc/gcc/hash-table.h:1194 // 0xb735f8 poplevel(int, int, int) // /root/gdbtest/gcc/obj/../gcc/gcc/cp/decl.cc:650 // 0xd04842 do_poplevel(tree_node*) // /root/gdbtest/gcc/obj/../gcc/gcc/cp/semantics.cc:651 // 0xd07599 finish_compound_stmt(tree_node*) // /root/gdbtest/gcc/obj/../gcc/gcc/cp/semantics.cc:1996 // 0xc59a4c cp_parser_compound_statement // /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:13287 // 0xc7ccd5 cp_parser_function_body // /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:26072 // 0xc7ccd5 cp_parser_ctor_initializer_opt_and_function_body // /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:26123 // 0xc8241e cp_parser_function_definition_after_declarator // /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:32903 // 0xc835be cp_parser_function_definition_from_specifiers_and_declarator // /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:32820 // 0xc835be cp_parser_init_declarator // /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:23451 // 0xc5668f cp_parser_simple_declaration // /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:15958 // 0xc8ffea cp_parser_declaration // /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:15631 // 0xc90fea cp_parser_toplevel_declaration // /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:15652 // 0xc90fea cp_parser_translation_unit // /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:5284 // 0xc90fea c_parse_file() // /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:51440 // 0xddf371 c_common_parse_file() // /root/gdbtest/gcc/obj/../gcc/gcc/c-family/c-opts.cc:1311 // Please submit a full bug report, with preprocessed source. // Please include the complete backtrace with any bug report. // See <https://gcc.gnu.org/bugs/> for instructions. // /root/gdbtest/gcc/gcc-15/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/cc1plus -fpreprocessed 1.ii -quiet -dumpdir -c- -dumpbase 1.ii -dumpbase-ext .ii -mtune=generic -march=x86-64 -O3 -Wall -Wextra -Wpedantic -std=c11 -fsanitize=undefined -fstack-protector-all -freport-bug -o - -frandom-seed=0 -fdump-noaddr # 0 "1.ii" # 0 "<built-in>" # 0 "<command-line>" # 1 "/usr/include/stdc-predef.h" 1 3 4 # 0 "<command-line>" 2 # 1 "1.ii" int fn1() { int **c; b = &&c; goto * 0} ******************************************************************************* Also ICE on trunk, compiler explorer:https://godbolt.org/z/jWYrKcqo6 *******************************************************************************