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

            Bug ID: 117237
           Summary: wrong code at -O{s,2,3} with "-fno-tree-fre
                    -fno-tree-pre -fno-code-hoisting -fno-inline" 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 regression from 11.* and affects 12.* and later.

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

[519] % 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 20241020 (experimental) (GCC) 
[520] % 
[520] % gcctk -O3 small.c; ./a.out
[521] % 
[521] % gcctk -O3 -fno-tree-fre -fno-tree-pre -fno-code-hoisting -fno-inline
small.c
[522] % ./a.out
Segmentation fault
[523] % 
[523] % cat small.c
struct a {
  int b;
};
int d, e;
const struct a c;
int f(struct a g) { return g.b; }
static void h(const struct a g) {
  d = f(g);
  e = g.b;
  1 ^ g.b;
}
int main() { h(c); }

Reply via email to