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

            Bug ID: 125962
           Summary: ICE on invalid code on x86_64-linux-gnu: tree check:
                    expected class ‘type’, have ‘exceptional’ (error_mark)
                    in element_mode, at tree.cc:13731
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

Compiler Explorer: https://godbolt.org/z/TWG3386qn

Note:
- fails: 12.1 till trunk
- works: 11.4 and earlier


[509] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/17.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++,lto --disable-werror
--disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 17.0.0 20260623 (experimental) (GCC) 
[510] % 
[510] % gcctk -O0 -c small.c 
small.c: In function ‘b’:
small.c:6:7: error: conflicting types for ‘c’; have ‘int’
    6 |   int c = 0;
      |       ^
small.c:3:9: note: previous definition of ‘c’ with type ‘float’
    3 |   float c = 0.0;
      |         ^
small.c:4:6: internal compiler error: tree check: expected class ‘type’, have
‘exceptional’ (error_mark) in element_mode, at tree.cc:13731
    4 |   if (c > 0.0 ? a : 1)
      |      ^
0x268174b internal_error(char const*, ...)
        ../../gcc-trunk/gcc/diagnostic-global-context.cc:787
0x931422 tree_class_check_failed(tree_node const*, tree_code_class, char
const*, int, char const*)
        ../../gcc-trunk/gcc/tree.cc:9269
0x938179 tree_class_check(tree_node const*, tree_code_class, char const*, int,
char const*)
        ../../gcc-trunk/gcc/tree.h:4235
0x938179 element_mode(tree_node const*)
        ../../gcc-trunk/gcc/tree.cc:13731
0x114aedc HONOR_NANS(tree_node const*)
        ../../gcc-trunk/gcc/real.cc:5527
0xda0b48 fold_truth_not_expr
        ../../gcc-trunk/gcc/fold-const.cc:4529
0xda0b48 fold_unary_loc(unsigned long, tree_code, tree_node*, tree_node*)
        ../../gcc-trunk/gcc/fold-const.cc:9422
0xdb1859 fold_ternary_loc(unsigned long, tree_code, tree_node*, tree_node*,
tree_node*, tree_node*)
        ../../gcc-trunk/gcc/fold-const.cc:12874
0xdb2f0b fold_build3_loc(unsigned long, tree_code, tree_node*, tree_node*,
tree_node*, tree_node*)
        ../../gcc-trunk/gcc/fold-const.cc:13674
0xd9f253 fold_unary_loc(unsigned long, tree_code, tree_node*, tree_node*)
        ../../gcc-trunk/gcc/fold-const.cc:9123
0xda184d fold_build1_loc(unsigned long, tree_code, tree_node*, tree_node*)
        ../../gcc-trunk/gcc/fold-const.cc:13568
0xea818b gimplify_cond_expr
        ../../gcc-trunk/gcc/gimplify.cc:5486
0xe8bf68 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc-trunk/gcc/gimplify.cc:20328
0xe8dbba gimplify_stmt(tree_node**, gimple**)
        ../../gcc-trunk/gcc/gimplify.cc:8539
0xe8a8fb gimplify_statement_list
        ../../gcc-trunk/gcc/gimplify.cc:2135
0xe8a8fb gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc-trunk/gcc/gimplify.cc:20825
0xe8dbba gimplify_stmt(tree_node**, gimple**)
        ../../gcc-trunk/gcc/gimplify.cc:8539
0xe8f244 gimplify_bind_expr
        ../../gcc-trunk/gcc/gimplify.cc:1530
0xe8addf gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc-trunk/gcc/gimplify.cc:20575
0xeab6c6 gimplify_stmt(tree_node**, gimple**)
        ../../gcc-trunk/gcc/gimplify.cc:8539
/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/17.0.0/cc1
-quiet -I /usr/local/include -I /local/suz-local/software/local/include
-imultiarch x86_64-linux-gnu -iprefix
/local/home/suz/suz-local/software/local/gcc-trunk/bin/../lib/gcc/x86_64-pc-linux-gnu/17.0.0/
small.c -quiet -dumpbase small.c -dumpbase-ext .c -mtune=generic -march=x86-64
-O0 -o /tmp/cccyw660.s
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.
[511] % 
[511] % cat small.c 
int a;
void b() {
  float c = 0.0;
  if (c > 0.0 ? a : 1)
    ;
  int c = 0;
}
  • [Bug c/125962] New: ICE on inv... zhendong.su at inf dot ethz.ch via Gcc-bugs

Reply via email to