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

            Bug ID: 115579
           Summary: wrong code at -Os with "-fno-tree-sra" 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: ---

It appears to be a very recent regression as it doesn't reproduce with 14.1. 

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


[572] % 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/15.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 15.0.0 20240620 (experimental) (GCC) 
[573] % 
[573] % gcctk -Os small.c; ./a.out
[574] % 
[574] % gcctk -Os -fno-tree-sra small.c
[575] % ./a.out
Aborted
[576] % 
[576] % cat small.c
int printf(const char *, ...);
int a, b = 1, c;
int main() {
  int d[2], *e = &d[1];
  while (a) {
    int *f = &b;
    d[1] = 0;
    *f = 0;
  }
  if (c)
    printf("%d\n", *e);
  if (b != 1)
    __builtin_abort();
  return 0;
}

Reply via email to