https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108867
Bug ID: 108867
Summary: RFE: analyzer could suppress false positives by
detecting functions that are likely missing
__attribute__((noreturn))
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: analyzer
Assignee: dmalcolm at gcc dot gnu.org
Reporter: dmalcolm at gcc dot gnu.org
Target Milestone: ---
Created attachment 54498
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54498&action=edit
Reproducer
The attached (from Doom) has 31 false positives from
-Wanalyzer-use-of-uninitialized-value, and a -Wanalyzer-null-dereference
diagnostic:
https://godbolt.org/z/h4qadxfK9
I think all of the uninit warnings follow calls to I_Error, which is defined in
a different TU (i_system.c), and calls exit(-1).
If I manually add __attribute__((noreturn)) to I_Error, then all of the
-Wanalyzer-use-of-uninitialized-value go away:
https://godbolt.org/z/Gb7P5hK11
leaving just the -Wanalyzer-null-dereference diagnostic.
RFE: try to detect likely candidates for __attribute__((noreturn)), and use
them to suppress such warnings (with a note informing the user when it's done,
and a fix-it hint).
That said, I think many of the uninit false +ves are follow-on warnings, where
we should only warn about the first use of an uninit value in an execution
path, and not on subsequent ones.