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

            Bug ID: 125612
           Summary: wrong code at -O3 with "-fno-tree-dse -fno-tree-dce"
                    on x86_64-linux-gnu
           Product: gcc
           Version: 16.0
            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: ---

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

Note:
- fails: trunk (nondeterministic) 
- works: 16.1 and earlier


[524] % 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/17.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 17.0.0 20260604 (experimental) (GCC) 
[525] % 
[525] % gcctk -O3 small.c; ./a.out
[526] % 
[526] % gcctk -O3 -fno-tree-dse -fno-tree-dce small.c
[527] % ./a.out
Segmentation fault
[528] % ./a.out
[529] % ./a.out
Segmentation fault
[530] % ./a.out
Segmentation fault
[531] % ./a.out
Segmentation fault
[532] % cat small.c
int a, b, c = 2, d, e[4], f, i;
void g() {
  int h[5];
  e[0] = 2;
  while (1) {
    if (e[b]) {
      if (!c)
        h[2000] &= d;
      return;
    }
  }
}
int main() {
  for (; i < 4; i++)
    g();
  return 0;
}

Reply via email to