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

            Bug ID: 126171
           Summary: [16.1 / 17.0 Regression] miscompilation at -O2
                    -flto=auto on x86_64-linux-gnu
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: SchWiniX at proton dot me
  Target Milestone: ---

Created attachment 64968
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=64968&action=edit
faulty test case

Godbolt: https://godbolt.org/z/Thq881snc

Fails on trunk (Most recent commit
https://gcc.gnu.org/cgit/gcc/commit/?id=cc2a9b13bbf9994f5f27c08a95314b07f4dd7730),
Works on 15.3

Further with flto enabled via -flto=auto, the test case fails for all version
up and including 8.1.

Target: x86_64-pc-linux-gnu
Configured with: ../configure --disable-multilib --host=x86_64-pc-linux-gnu
--enable-languages=c --with-ld=/usr/bin/ld.lld : (reconfigured) ../configure
--disable-m
ultilib --host=x86_64-pc-linux-gnu --enable-languages=c
--with-ld=/usr/bin/ld.lld : (reconfigured) ../configure --disable-multilib
--host=x86_64-pc-linux-gnu --with
-ld=/usr/bin/ld.lld host_alias=x86_64-pc-linux-gnu --enable-languages=c,c++,lto
--no-create --no-recursion
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 17.0.0 20260704 (experimental) (GCC) 

Command line for reproduction: gcc -O2 reduced.c

The compiler outputs no warnings. And Sanitizers do not report any runtime
errors. Tho they do fix the miscompilation

-fwrapv does also fix the segmentation fault but I believe this still to be
valid C code. I've both manually reviewed it for UB as well as used CompCert's
-interp  -fall mode to validate.

Reply via email to