******************************************************************************* The compiler produces a segfault during gimple_build_switch_nlabels at gimple.cc807 when compiling the provided code with the specified options. The issue can also be reproduced on Compiler Explorer. ******************************************************************************* 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 ******************************************************************************* # gcc -v Using built-in specs. COLLECT_GCC=gcc 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 test035.c __GIMPLE a(argc) { switch (argc_20) { case 1: b; } ******************************************************************************* Command Lines: # gcc test035.c -O2 -fdump-tree-gimple -fdump-tree-switchconv -Wall -c -o test035.o test035.c:1:1: error: ‘__GIMPLE’ only valid with ‘-fgimple’ 1 | __GIMPLE a(argc) { | ^~~~~~~~ test035.c:1:10: error: return type defaults to ‘int’ [-Wimplicit-int] 1 | __GIMPLE a(argc) { | ^ test035.c: In function ‘a’: test035.c:1:10: error: type of ‘argc’ defaults to ‘int’ [-Wimplicit-int] test035.c:5:3: internal compiler error: in gimple_build_switch_nlabels, at gimple.cc:807 5 | } | ^ 0x7e5713 gimple_build_switch_nlabels(unsigned int, tree_node*, tree_node*) /root/gdbtest/gcc/obj/../gcc/gcc/gimple.cc:807 0x7e5713 gimple_build_switch_nlabels(unsigned int, tree_node*, tree_node*) /root/gdbtest/gcc/obj/../gcc/gcc/gimple.cc:804 0xd09040 gimple_build_switch(tree_node*, tree_node*, vec<tree_node*, va_heap, vl_ptr> const&) /root/gdbtest/gcc/obj/../gcc/gcc/gimple.cc:827 0xa64ac1 c_parser_gimple_switch_stmt /root/gdbtest/gcc/obj/../gcc/gcc/c/gimple-parser.cc:2552 0xa64ac1 c_parser_gimple_compound_statement /root/gdbtest/gcc/obj/../gcc/gcc/c/gimple-parser.cc:440 0xa64d61 c_parser_parse_gimple_body(c_parser*, char*, c_declspec_il, profile_count) /root/gdbtest/gcc/obj/../gcc/gcc/c/gimple-parser.cc:253 0xa505a4 c_parser_declaration_or_fndef /root/gdbtest/gcc/obj/../gcc/gcc/c/c-parser.cc:3011 0xa5af4b c_parser_external_declaration /root/gdbtest/gcc/obj/../gcc/gcc/c/c-parser.cc:2046 0xa5b935 c_parser_translation_unit /root/gdbtest/gcc/obj/../gcc/gcc/c/c-parser.cc:1900 0xa5b935 c_parse_file() /root/gdbtest/gcc/obj/../gcc/gcc/c/c-parser.cc:26889 0xad3a51 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 (by using -freport-bug). Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. ******************************************************************************* Also ICE on trunk, compiler explorer:https://godbolt.org/z/5sYY7a47c *******************************************************************************
With a better testcase error-recovery could be avoided. Note that the GIMPLE parser doesn't impose all GIMPLE constraints but relies on the verifier. This IL part (default label present) is instead verified by an assert.