https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117667
Bug ID: 117667 Summary: -flto=auto prevents -fanalyzer from reporting any warnings on a build of systemd Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: analyzer Assignee: dmalcolm at gcc dot gnu.org Reporter: kdudka at redhat dot com Target Milestone: --- As originally reported by František Šumšal at https://lists.fedoraproject.org/archives/list/de...@lists.fedoraproject.org/message/2DXE6BMG3A3J72PDWUGZSEIKNHILUKR3/ -flto=auto prevents -fanalyzer from reporting any warnings on a build of systemd. Steps to reproduce: 1. compile/analyze without -flto=auto % git clone https://github.com/systemd/systemd.git % git reset --hard https://github.com/systemd/systemd.git % CC=/opt/gcc-latest/bin/gcc meson build -Dc_args="-fanalyzer -fdiagnostics-format=sarif-file" % ninja -C build systemd % find -name \*.sarif | xargs csgrep --mode=evtstat 1 COMPILER_WARNING warning[-Wunterminated-string-initialization] 1 GCC_ANALYZER_WARNING warning[-Wanalyzer-allocation-size] 34 GCC_ANALYZER_WARNING warning[-Wanalyzer-double-free] 12 GCC_ANALYZER_WARNING warning[-Wanalyzer-fd-leak] 1 GCC_ANALYZER_WARNING warning[-Wanalyzer-fd-phase-mismatch] 1 GCC_ANALYZER_WARNING warning[-Wanalyzer-file-leak] 1 GCC_ANALYZER_WARNING warning[-Wanalyzer-infinite-loop] 100 GCC_ANALYZER_WARNING warning[-Wanalyzer-malloc-leak] 1 GCC_ANALYZER_WARNING warning[-Wanalyzer-mismatching-deallocation] 7 GCC_ANALYZER_WARNING warning[-Wanalyzer-null-argument] 30 GCC_ANALYZER_WARNING warning[-Wanalyzer-null-dereference] 21 GCC_ANALYZER_WARNING warning[-Wanalyzer-out-of-bounds] 3 GCC_ANALYZER_WARNING warning[-Wanalyzer-use-after-free] 57 GCC_ANALYZER_WARNING warning[-Wanalyzer-use-of-uninitialized-value] 2 GCC_ANALYZER_WARNING warning[-Wanalyzer-va-list-exhausted] 2. compile/analyze with -flto=auto % git clean -dfx % CC=/opt/gcc-latest/bin/gcc meson build -Dc_args="-fanalyzer -fdiagnostics-format=sarif-file -flto=auto" % ninja -C build systemd % find -name \*.sarif | xargs csgrep --mode=evtstat 1 COMPILER_WARNING warning[-Wunterminated-string-initialization] That is, with -flto=auto, all the warnings from gcc analyzer silently disappear (and the compilation runs apparently faster). I am able to reproduce this with gcc-14.2.1-3.fc40.x86_64 as well as gcc-latest-15.0.0-4.20241020git01f50ebfd97a.pr116613.v0.155.fc40.x86_64 installed from https://copr.fedorainfracloud.org/coprs/dmalcolm/gcc-latest/