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

--- Comment #3 from Zhendong Su <zhendong.su at inf dot ethz.ch> ---
Another likely related instance that is miscompiled at -Os, -O2 and -O3.

Compiler Explorer: https://godbolt.org/z/3TbG51Ph3

[628] % 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.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
--with-system-zlib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 13.0.0 20221015 (experimental) [master r13-3311-gbaeec7cc83b] (GCC) 
[629] % 
[629] % gcctk -O1 small.c; ./a.out
[630] % 
[630] % gcctk -Os small.c
[631] % timeout -s 9 5 ./a.out
Killed
[632] % 
[632] % cat small.c
struct a {
  int b;
};
int c;
int main() {
  struct a d = {0};
  int e;
  short f = 1;
  for (; c < 1; c++) {
    if (d.b < 1)
      e = -~(f ^ 500000000L ^ -1);
    f = e;
    while (e > -100000)
      ;
  }
  return 0;
}

Reply via email to