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

            Bug ID: 110509
           Summary: wrong code at -O3 on x86_64-linux-gnu
                    (nondeterministic hang)
           Product: gcc
           Version: unknown
            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: ---

This appears to be a recent regression.

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

[521] % 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/14.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
--disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230701 (experimental) (GCC) 
[522] % 
[522] % gcctk -O3 small.c
[523] % for i in $(seq 1 10); do
> echo $i
> timeout -s 9 5 ./a.out
> done
1
2
3
4
Killed
5
6
7
Killed
8
Killed
9
Killed
10
Killed
[524] % 
[524] % cat small.c
int printf (const char *, ...);
int a, d = 10, b = 8, c, e, i, r, f, j;
int g (short l) {
  if (d)
    return l;
}
int main () {
  int m[] = {987, 1, 47}, p, o = 2;
 L1:
  p = g (m[2] >= 8);
  while (1) {
    while (p > 1)
      while (r) {
        int h = m[a];
        while (1)
          ;
      }
    while (i < 9) {
      if (c && f) {
        if (o) {
          p = 7 ^ j;
          b = o = 0;
          if (p <= 4) {
            printf ("%d", j);
            goto L2;
          }
        }
        if (j)
          goto L1;
      L2:
        b > 1;
      }
      if (b)
        return e;
    }
  }
  return 0;
}

Reply via email to