[Bug c++/86176] Wnull-dereference warning disappears with a call to std::cout on the line after
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Jun 18 08:23:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86176
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2018-06-18
Ever confirmed|0 |1
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
The warning depends on inlining which makes it require -O2 in your case and
with the cout line uncommented the inlining doesn't take place because of cost
reasons. Making f static shows
> g++-7 t.C -O2 -Wnull-dereference
t.C: In function ‘int main()’:
t.C:6:11: warning: null pointer dereference [-Wnull-dereference]
printf("%d\n", *i);
~~~~~~^~~~~~~~~~~~
t.C:7:19: warning: null pointer dereference [-Wnull-dereference]
std::cout << *i;
^
so confirmed but the issues are by design. GCC isn't a static analyzer.
More information about the Gcc-bugs
mailing list