https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100578
Bug ID: 100578 Summary: [12 Regression] ICE Segmentation fault during GIMPLE pass: fre (under -g -O2/O3/Os) Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: haoxintu at gmail dot com Target Milestone: --- Hi all. $cat small.c #include <stdint.h> void a() { int b; c: int8_t d = 3; if (b |= d ^= a >= 5) ; else goto c; } $gcc -w -g -O2 (same as -O3 and -Os) during GIMPLE pass: fre small.c: In function ‘a’: small.c:2:6: internal compiler error: Segmentation fault 2 | void a() { | ^ 0xba009f crash_signal ../../gcc/toplev.c:327 0xd1a01e eliminate_dom_walker::eliminate_stmt(basic_block_def*, gimple_stmt_iterator*) ../../gcc/tree-ssa-sccvn.c:6336 0xd1b64d eliminate_dom_walker::before_dom_children(basic_block_def*) ../../gcc/tree-ssa-sccvn.c:6579 0xd1b64d eliminate_dom_walker::before_dom_children(basic_block_def*) ../../gcc/tree-ssa-sccvn.c:6512 0x144e967 dom_walker::walk(basic_block_def*) ../../gcc/domwalk.c:309 0xd12f10 eliminate_with_rpo_vn(bitmap_head*) ../../gcc/tree-ssa-sccvn.c:6759 0xd21d03 do_rpo_vn ../../gcc/tree-ssa-sccvn.c:7872 0xd22a90 execute ../../gcc/tree-ssa-sccvn.c:7954 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. Note that this only crashes on the current trunk version of GCC, and I don't see any crash on released GCC versions. The output in Godbolt (https://godbolt.org/z/bbjnbGYb4) is: ``` #1 with x86-64 gcc (trunk) during GIMPLE pass: evrp <source>: In function 'a': <source>:10:1: internal compiler error: tree check: expected class 'type', have 'exceptional' (error_mark) in useless_type_conversion_p, at gimple-expr.c:87 10 | } ``` Another interesting behavior is that GCC-11 accepts this code while GCC-10 downwards versions reject it. GCC-10 output is (in https://godbolt.org/z/W34EnfhqM): ``` <source>5:3: error: a label can only be part of a statement and a declaration is not a statement 5 | int8_t d = 3; | ^~~~~~ ``` GCC version in my machine is: $gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/home/tuhaoxin/compilers/gcc/build/libexec/gcc/x86_64-pc-linux-gnu/12.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../configure --prefix=/home/tuhaoxin/compilers/gcc/build/ --enable-bootstrap --enable-checking=release --enable-languages=c,c++ -disable-multilib Thread model: posix Supported LTO compression algorithms: zlib gcc version 12.0.0 20210510 (experimental) (GCC) Thanks, Haoxin