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

            Bug ID: 119773
           Summary: 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: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: chopra.kavya04 at gmail dot com
  Target Milestone: ---

This bug's a weird one - it seems to compile just fine, but hangs at -O1 and
above for the current gcc trunk version. Godbolt link:
https://godbolt.org/z/avWdq5Y5v

kchopra@ast-epyc5:~$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/local/home/kchopra/compilers/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/compilers/
--with-local-prefix=/local/home/kchopra/compilers/
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 15.0.1 20250408 (experimental) (GCC) 
kchopra@ast-epyc5:~$ gcc -O0 bug_3.c -fsanitize=undefined; ./a.out
kchopra@ast-epyc5:~$ gcc -O3 bug_3.c; timeout -s 9 10 ./a.out 
Killed
kchopra@ast-epyc5:~$ cat bug_3.c 
int a = 1, b, c = 1, d;
int main() {
e:
 d = 1 - a;
 if (d + c <= 0)
  goto g;
 b = 1 - a;
 if (b - 2147483647 * c >= 0)
  goto g;
 b = 1;
 c = 0;
 goto e;
g:
 if (b)
  return 0;
 goto e;
}

Reply via email to