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

            Bug ID: 125652
           Summary: wrong code at -O3 on x86_64-linux-gnu
           Product: gcc
           Version: 16.0
            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/zqKP97znf

Note:
- fails: 16.1 and trunk
- works: 15.2 and earlier


[857] % 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/17.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 17.0.0 20260604 (experimental) (GCC) 
[858] % 
[858] % gcctk -O2 small.c; ./a.out
[859] % 
[859] % gcctk -O3 small.c
[860] % ./a.out
Illegal instruction
[861] % 
[861] % cat small.c
int a, b, c, d;
void e(long f, long g) {
  long h = 1, *i, **j;
  while (1) {
    i = &h;
    j = &i;
    if (h <= h + f - ~h)
      break;
    *i += g;
  }
  c *= 2;
  d = a >> b + d;
}
int main () {
  e(-2147483627, 4611686018427387904);
  return 0;
}

Reply via email to