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

            Bug ID: 120322
           Summary: wrong code at -O{s,2,3} with "-fno-early-inlining" 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: ---

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

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


[508] % 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/16.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 16.0.0 20250517 (experimental) (GCC) 
[509] % 
[509] % gcctk -O3 small.c; ./a.out
[510] % 
[510] % gcctk -O3 -fno-early-inlining small.c
[511] % ./a.out
Segmentation fault
[512] % 
[512] % cat small.c
int a, b, c;
void d(int e) {
  if (e > 0)
    while (b)
      ;
}
void f(unsigned short e) { d(e); }
static void g(short e) {
  f(e);
  c = a;
}
int main() { g(-1); }

Reply via email to