https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115472

            Bug ID: 115472
           Summary: ICE :tree check expected class 'type', have
                    'exceptional' (error_mark) in check_goto_1, at
                    cpdecl.cc4007
           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 check_goto_1, at cpdecl.cc4007.
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:
# interpret.ii

int a(void) {
  &&b;
b:
  c;
  goto * 0
}

*******************************************************************************
Command Lines:
# g++ interpret.ii -O3 -Wall -Wextra -std=c11 -pedantic
-fsanitize=undefined,address -fstack-protector-all -D_FORTIFY_SOURCE=2
-fno-strict-aliasing -Wshadow -Wstrict-aliasing=2 -fno-omit-frame-pointer
-freport-bug -c -o interpret.o
cc1plus: warning: command-line option ‘-std=c11’ is valid for C/ObjC but not
for C++
interpret.ii: In function ‘int a()’:
interpret.ii:2:5: warning: taking the address of a label is non-standard
[-Wpedantic]
    2 |   &&b;
      |     ^
interpret.ii:2:3: warning: statement has no effect [-Wunused-value]
    2 |   &&b;
      |   ^~~
interpret.ii:4:3: error: ‘c’ was not declared in this scope
    4 |   c;
      |   ^
interpret.ii:5:3: warning: ISO C++ forbids computed gotos [-Wpedantic]
    5 |   goto * 0
      |   ^~~~
interpret.ii:5:10: internal compiler error: tree check: expected class ‘type’,
have ‘exceptional’ (error_mark) in check_goto_1, at cp/decl.cc:4004
    5 |   goto * 0
      |          ^
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
0x7cab4f tree_class_check(tree_node*, tree_code_class, char const*, int, char
const*)
        /root/gdbtest/gcc/obj/../gcc/gcc/tree.h:3779
0x7cab4f check_goto_1(named_label_entry*, bool)
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/decl.cc:4004
0xb72b89 check_goto(tree_node*)
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/decl.cc:4042
0xd04969 finish_goto_stmt(tree_node*)
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/semantics.cc:840
0xc85c05 cp_parser_jump_statement
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:14914
0xc85c05 cp_parser_statement
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:12743
0xc59807 cp_parser_statement_seq_opt
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:13427
0xc59a2f cp_parser_compound_statement
        /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:13281
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/cc5yqZYl.out file, please attach this to
your bugreport.

*******************************************************************************

#cat /tmp/cc5yqZYl.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++
// interpret.ii: In function ‘int a()’:
// interpret.ii:2:5: warning: taking the address of a label is non-standard
[-Wpedantic]
//     2 |   &&b;
//       |     ^
// interpret.ii:2:3: warning: statement has no effect [-Wunused-value]
//     2 |   &&b;
//       |   ^~~
// interpret.ii:4:3: error: ‘c’ was not declared in this scope
//     4 |   c;
//       |   ^
// interpret.ii:5:3: warning: ISO C++ forbids computed gotos [-Wpedantic]
//     5 |   goto * 0
//       |   ^~~~
// interpret.ii:5:10: internal compiler error: tree check: expected class
‘type’, have ‘exceptional’ (error_mark) in check_goto_1, at cp/decl.cc:4004
//     5 |   goto * 0
//       |          ^
// 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
// 0x7cab4f tree_class_check(tree_node*, tree_code_class, char const*, int,
char const*)
//      /root/gdbtest/gcc/obj/../gcc/gcc/tree.h:3779
// 0x7cab4f check_goto_1(named_label_entry*, bool)
//      /root/gdbtest/gcc/obj/../gcc/gcc/cp/decl.cc:4004
// 0xb72b89 check_goto(tree_node*)
//      /root/gdbtest/gcc/obj/../gcc/gcc/cp/decl.cc:4042
// 0xd04969 finish_goto_stmt(tree_node*)
//      /root/gdbtest/gcc/obj/../gcc/gcc/cp/semantics.cc:840
// 0xc85c05 cp_parser_jump_statement
//      /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:14914
// 0xc85c05 cp_parser_statement
//      /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:12743
// 0xc59807 cp_parser_statement_seq_opt
//      /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:13427
// 0xc59a2f cp_parser_compound_statement
//      /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:13281
// 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 interpret.ii -quiet -dumpbase interpret.ii -dumpbase-ext .ii
-mtune=generic -march=x86-64 -O3 -Wall -Wextra -Wpedantic -Wshadow
-Wstrict-aliasing=2 -std=c11 -fsanitize=undefined,address -fstack-protector-all
-fno-strict-aliasing -fno-omit-frame-pointer -freport-bug -o - -frandom-seed=0
-fdump-noaddr

# 0 "interpret.ii"
# 0 "<built-in>"
# 0 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 0 "<command-line>" 2
# 1 "interpret.ii"
int a(void) {
  &&b;
b:
  c;
  goto * 0
}


*******************************************************************************

Also ICE on trunk, compiler explorer:https://godbolt.org/z/zdnj39qTn

*******************************************************************************
  • [Bug c++/115472] New: ICE :t... iamanonymous.cs at gmail dot com via Gcc-bugs

Reply via email to