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

--- Comment #4 from Zhendong Su <zhendong.su at inf dot ethz.ch> ---
Another likely related reproducer that affects 9.* and later.

Compiler Explorer: https://godbolt.org/z/8vTd7rx6d

[641] % 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 20230629 (experimental) [master r14-924-gd709841ae0f] (GCC) 
[642] % 
[642] % gcctk -O2 -fselective-scheduling2 -fno-tree-pre small.c
[643] % ./a.out
34
[644] % gcctk -O2 small.c
[645] % ./a.out
1
[646] % cat small.c
int printf(const char *, ...);
int a, b;
int main() {
  unsigned int c = 0;
  unsigned char d = 33;
  for (; a < 1; a++) {
    unsigned int e = 0;
    unsigned char f = 0;
    if (c < 1) {
      e = f = d;
      c = b * 4;
      if (c < b)
        printf("%ld", (long)d);
      if (!f)
        break;
    }
    c = e;
    d = f;
  }
  printf("%d\n", a);
  return 0;
}

Reply via email to