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

            Bug ID: 124325
           Summary: wrong code at -O{s,2,3} with -fmerge-all-constants 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/j9535acs1

Note: it fails with 5.1 and later.

[509] % 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.1/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.1 20260226 (experimental) (GCC) 
[510] % 
[510] % gcctk -O3 -w small.c; ./a.out
[511] % gcctk -O3 -w -fmerge-all-constants small.c
[512] % ./a.out
Aborted
[513] % 
[513] % cat small.c
int a, b, *f = &a;
int *const c = &b;
int const *const d = &b;
int const **e = &d;
int main() {
  *f = &c == e;
  if (a != 0)
    __builtin_abort();
  return 0;
}

Reply via email to