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

            Bug ID: 119690
           Summary: [12/13/14 regression] wrong code at -O{s,1,2,3} on
                    x86_64-linux-gnu
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: chopra.kavya04 at gmail dot com
  Target Milestone: ---

The bug wasn't there in gcc11, and has been affecting subsequent versions
since. 
Here's the compiler explorer link for the bug:  https://godbolt.org/z/1rYcd3GTY


kchopra@su-lee:~$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/local/home/kchopra/.gcclocal/libexec/gcc/x86_64-pc-linux-gnu/15.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --prefix=/local/home/kchopra/.gcclocal/
--with-local-prefix=/local/home/kchopra/.gcclocal/
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.1 20250404 (experimental) (GCC) 
kchopra@su-lee:~$ gcc -O3 small.c ; ./a.out
0
kchopra@su-lee:~$ gcc -O0 small.c ; ./a.out
1
kchopra@su-lee:~$ cat small.c
int printf(const char *, ...);
int a, b = -2147483647, c;
int main() {
d:
 c = a + b + 2147483647;
 if (-c >= 0)
  goto e;
 goto f;
e:
 a = c + 1;
 goto d;
f:
 printf("%d\n", a);
 return 0;
}
kchopra@su-lee:~$

Reply via email to