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

--- Comment #4 from Zhendong Su <zhendong.su at inf dot ethz.ch> ---
Here is another likely related test (which is also valid) that only hangs at
-Os.

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

[512] % 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 20250616 (experimental) (GCC) 
[513] % 
[513] % time gcctk -O2 small.c

real    0m0.217s
user    0m0.069s
sys     0m0.014s
[514] % time gcctk -O3 small.c

real    0m0.225s
user    0m0.081s
sys     0m0.007s
[515] % 
[515] % timeout -s 9 30 gcctk -Os small.c
Killed
[516] % cat small.c
#include <stdarg.h>
int e, a, b;
int f(int b, ...) {
  va_list args;
  va_start(args, b);
  unsigned c = 1;
  for (int d; d < b; ++d)
    c = c ^ 1;
  return c;
}
static int fn3(int l, int i, int n) {
  int j;
  goto k;
r:
  j = (f(e) + 1641730381) * l + 1189664732 * n + 1064 * i - 1545337304;
  if (903562339 * j + n >= 0)
    goto m;
  goto ac;
k:
  if (0)
    goto ad;
  goto t;
ad:
  if (b)
    goto s;
  goto r;
m:
  goto ad;
t:
  j = l;
  l = 800794 * j;
  goto ad;
s:
  b = 2 * b + 1;
  if (a + (long)j)
    goto t;
  i = n;
  goto s;
ac:
}
int main() {
  if (a)
    if (fn3(-1, 1, -1))
      fn3(1, 0, 3);
  return 0;
}

Reply via email to