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

            Bug ID: 120560
           Summary: wrong code at -O{s,2,3} with -fno-tree-ccp on
                    x86_64-linux-gnu
           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: ---

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

It appears to be a regression from 13.* and affects 14.* and later.

[602] % 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/16.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 16.0.0 20250605 (experimental) (GCC) 
[603] % 
[603] % gcctk -O3 small.c; ./a.out
[604] % 
[604] % gcctk -O3 -fno-tree-ccp small.c
[605] % ./a.out
Segmentation fault
[606] % 
[606] % cat small.c
int main() {
  int a = -1, b = 2, c = 1;
  if (a >= 0)
    c = 0;
  while (1) {
    if (-b + c - 7 >= 0)
      return 0;
    b = b - 1000 - 2147482648;
  }
}

Reply via email to