https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112333
Bug ID: 112333 Summary: ICE on valid code at -O2 and -O3: Segmentation fault Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: zhendong.su at inf dot ethz.ch Target Milestone: --- It appears to be a recent regression. Compiler Explorer: https://godbolt.org/z/z8fo6PvPh With my local build, -g is needed to reproduce the ICE. [512] % gcctk -v Using built-in specs. COLLECT_GCC=gcctk COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/14.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++ --disable-werror --enable-multilib Thread model: posix Supported LTO compression algorithms: zlib gcc version 14.0.0 20231101 (experimental) (GCC) [513] % [513] % gcctk -O3 -g small.c during GIMPLE pass: ccp small.c: In function ‘main’: small.c:3:5: internal compiler error: Segmentation fault 3 | int main() { | ^~~~ 0x111dc93 crash_signal ../../gcc-trunk/gcc/toplev.cc:315 0x7f658ef6c08f ??? /build/glibc-BHL3KM/glibc-2.31/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0 0xd70a7b gsi_for_stmt(gimple*) ../../gcc-trunk/gcc/gimple-iterator.cc:615 0x13a2e72 insert_debug_temp_for_var_def(gimple_stmt_iterator*, tree_node*) ../../gcc-trunk/gcc/tree-ssa.cc:471 0x13a329a insert_debug_temps_for_defs(gimple_stmt_iterator*) ../../gcc-trunk/gcc/tree-ssa.cc:506 0xd707e4 gsi_remove(gimple_stmt_iterator*, bool) ../../gcc-trunk/gcc/gimple-iterator.cc:567 0x12624c2 simple_dce_from_worklist(bitmap_head*, bitmap_head*) ../../gcc-trunk/gcc/tree-ssa-dce.cc:2206 0x1314c1a substitute_and_fold_engine::substitute_and_fold(basic_block_def*) ../../gcc-trunk/gcc/tree-ssa-propagate.cc:1001 0x1242db8 ccp_finalize ../../gcc-trunk/gcc/tree-ssa-ccp.cc:1031 0x1243468 do_ssa_ccp ../../gcc-trunk/gcc/tree-ssa-ccp.cc:2980 0x1243468 execute ../../gcc-trunk/gcc/tree-ssa-ccp.cc:3025 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. [514] % [514] % cat small.c int printf(const char *, ...); int a, b, c, d, e; int main() { long g; int h = a, i; if (e) goto j; i = 0; for (; i < 1; i++) { int k = d | c, l = ~a; if (k) { m: e = 0; j: b = l; if (c) goto m; } } if (a) { while (a > 1) a--; g = a; printf("%d", h); } while (a) ; return 0; }