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

--- Comment #1 from Zhendong Su <zhendong.su at inf dot ethz.ch> ---
Here is another related instance that also fails at -O3 (and 15.1).

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

[522] % 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 20250803 (experimental) (GCC) 
[523] % 
[523] % gcctk -O2 small.c; ./a.out
Aborted
[524] % gcctk -O3 small.c; ./a.out
Aborted
[525] % cat small.c
int a, b, c, f, h, j, k;
int l[] = {0, 4, 8, 4, 2044508324, 7, 4049, 8, 99276663, 107580753, 9,
           0, 2, 2, 6, 7, 5, 5, 7, 7073096, 6, 2, 2, 101629, 942443,
           -252153386, 8065728, 705015759, 5, 0, 6, 9554304,
           104598, 3, 1, 5, 3099436303, 4, 1796926599, 5, 5,
           3060149565, 2, 4, 2, 4023717930, 907459465, 5, 3,
           904427059, 2013776290, 6, 4, 0, 3, 3, 9, 7, 802195444, 6,
           8001368, 4066508878, 12370925, 3092731, 5, 3, 706088902,
           14042704, 2, 2, 1, 7, 3, 5, 303535960, 6, 7007092, 9037538,
           70817, 1, 5210733, 4079995, 6, 6, 909243462, 3771856, 7, 7,
           1, 708648649, 33948, 9306, 396048, 4, 909, 5, 10523913, 5,
           4, 702138776, 0, 2, 504918807, 3, 3082640443, 9, 4, 4646,
           7068, 57810842, 5, 1, 70997, 3, 0, 9596804, 5274430,
           2053790376, 5, 6906013, 3, 2097651377, 4027552580, 90386,
           2, 2050814, 5, 5, 6522225, 507879, 6, 0, 2753626, 2555852,
           708143, 5, 97917763, 7, 604390888, 8, 2, 6, 5, 60999,
           1068828381, 9, 0, 8, 906185462, 1090812512, 3, 9, 5, 1,
           12177804, 60834842, 801606440, 4, 6, 1, 5, 3, 1,
           607071920, 0, 2, 40735498, 5, 1, 13087877, 908371, 4,
           803740692, 2075208622, 2, 3, 90285, 2094854071, 1, 2029012,
           0, 2, 0, 1, 9329115, 1, 7, 4, 200368, 4, 6, 405801727, 5,
           5, 1, 5067896, 608007406, 308918612, 8, 808555105, 3, 1, 5,
           703836, 1088359270, 0, 9, 7, 3342108};
int m(int n, int o[]) {
  for (int i = 0; i < n; ++i) {
    k = l[c];
    b = l[k & 255];
    a = (b ^ o[i]) & 15;
    c = a;
  }
  return a;
}
static int p(int n, int o, int p3, int q, int r, int s) {
  f = -p3 - 999;
  do {
    h = j;
    j = -s - 999;
    if (j - h)
      goto t;
  u:
    if (n > 0)
      goto t;
    goto v;
  t:
    h = -j;
    r = r - o - 999;
  } while (h - 999 * r + f > 0);
  goto u;
v:
  return m(3, (int[]){2, q, r});
}
int main() {
  p(-2147483647, 2148635, 5986009, 8, 1, -2147483646) *
    p(-2147483647, -2147483647, -2147483647, 3647, -2147483647, -2147483647);
  if (a != 14)
    __builtin_abort();
  return 0;
}

Reply via email to