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

            Bug ID: 109138
           Summary: wrong code at -O1 and above on x86_64-linux-gnu
           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 long latent, affecting at least 5.* and later. 

Compiler Explorer: https://godbolt.org/z/9rb354E51

[592] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/13.0.1/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
--with-system-zlib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 13.0.1 20230315 (experimental) [master r13-6679-gfd42a8fa4b7] (GCC) 
[593] % 
[593] % gcctk -O0 small.c; ./a.out
[594] % 
[594] % gcctk -O1 small.c
[595] % timeout -s 9 5 ./a.out
Killed
[596] % 
[596] % cat small.c
unsigned a = -1;
int main() {
  int b = 0;
  for (; b < 2; b++) {
  L:;
    int d;
    while (a <= 0)
      if (*&d)
        break;
    d = 1;
    a++;
  }
  return 0;
}

Reply via email to