https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124502
Bug ID: 124502
Summary: Segmentation fault on invalid namespace definition
after anonymous inline namespace and enum
redeclaration
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: suyuchang at whu dot edu.cn
Target Milestone: ---
Code:
struct a;
inline namespace {
enum a {}
}
namespace a
Command:
g++ test.cpp
Output:
test.cpp:5:1: error: expected unqualified-id before ‘}’ token
5 | }
| ^
test.cpp:6:11: internal compiler error: Segmentation fault
6 | namespace a
| ^
0x2cb8d8e internal_error(char const*, ...)
../../gcc-trunk/gcc/diagnostic-global-context.cc:787
0x16f2b26 crash_signal
../../gcc-trunk/gcc/toplev.cc:325
0x7fe92cefa51f ???
./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0xdfe8d1 contains_struct_check(tree_node*, tree_node_structure_enum, char
const*, int, char const*)
../../gcc-trunk/gcc/tree.h:3925
0xdfe8d1 push_namespace(tree_node*, bool)
../../gcc-trunk/gcc/cp/name-lookup.cc:9399
0xe7fb63 cp_parser_namespace_definition
../../gcc-trunk/gcc/cp/parser.cc:24398
0xe80889 cp_parser_declaration
../../gcc-trunk/gcc/cp/parser.cc:17664
0xe83628 cp_parser_toplevel_declaration
../../gcc-trunk/gcc/cp/parser.cc:17705
0xe83628 cp_parser_translation_unit
../../gcc-trunk/gcc/cp/parser.cc:5596
0xe83628 c_parse_file()
../../gcc-trunk/gcc/cp/parser.cc:57467
0x1025990 c_common_parse_file()
../../gcc-trunk/gcc/c-family/c-opts.cc:1422
/home/syc/gcc-16.0/libexec/gcc/x86_64-pc-linux-gnu/16.0.1/cc1plus -quiet
-imultiarch x86_64-linux-gnu -D_GNU_SOURCE test.cpp -quiet -dumpdir a-
-dumpbase test.cpp -dumpbase-ext .cpp -mtune=generic -march=x86-64 -o
/tmp/ccc9Nyea.s
Goes back to a while:https://godbolt.org/z/vf7rvhhEq
The test case was generated by a fuzzer.