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

            Bug ID: 120258
           Summary: [11/12/13/14/15/16 regression] wrong code at
                    -O{s,1,2,3} on x86_64-linux-gnu
           Product: gcc
           Version: 16.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: ---

Appears to be a regression since gcc11. Godbolt link:
https://godbolt.org/z/aooh6xaj8

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/16.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --disable-bootstrap --enable-checking=yes
--prefix=/local/home/kchopra/compilers --enable-sanitizers
--enable-languages=c,c++ --disable-werror --enable-multilib : (reconfigured)
../configure --disable-bootstrap --enable-checking=yes
--prefix=/local/home/kchopra/compilers --enable-sanitizers
--enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 16.0.0 20250512 (experimental) (GCC) 
kchopra@ast-epyc5:~$ gcc -O1 bug_gcc_11.c 
kchopra@ast-epyc5:~$ ./a.out 
Aborted
kchopra@ast-epyc5:~$ cat bug_gcc_11.c 
int a = 1, b, c;
int main() {
  c = -2147483647 * b - 2147483647 * a;
  if (b - 2147483647 * a >= 0)
    __builtin_abort();
}

Reply via email to