[Bug c++/86176] Wnull-dereference warning disappears with a call to std::cout on the line after

2019-12-21 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86176

--- Comment #6 from Eric Gallager  ---
(In reply to Jonathan Wakely from comment #3)
> No, because GCC is not a static analyser.

It'll have one once David Malcolm's static analyzer branch is merged

[Bug c++/86176] Wnull-dereference warning disappears with a call to std::cout on the line after

2018-12-17 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86176

--- Comment #5 from Martin Sebor  ---
I think the question in comment #2 is whether it's possible to get the full
benefit of the latter kind of warnings without relying on the optimizations
being performed that they depend on.  There is currently no way to do decouple
the two: an inlining pass must run in order for the middle-end warnings that
detect bugs across function boundaries to trigger.

By "static analysis checkers" I meant all the warnings GCC emits today, mainly
either from the front-end (with almost no dependency on optimizations) or from
the middle-end (with the benefit of the optimizing passes).  I wasn't
suggesting to change GCC at this basic level (although suggestions along these
lines have been made in the past, in hopes that it would avoid some of the
false positives that GCC middle-end warnings are susceptible to).

[Bug c++/86176] Wnull-dereference warning disappears with a call to std::cout on the line after

2018-12-17 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86176

Eric Gallager  changed:

   What|Removed |Added

 CC||msebor at gcc dot gnu.org

--- Comment #4 from Eric Gallager  ---
(In reply to Jonathan Wakely from comment #3)
> No, because GCC is not a static analyser.

I thought one of Martin Sebor's talks at this year's Cauldron was about
implementing static analysis checkers in the middle-end:
https://gcc.gnu.org/wiki/cauldron2018#static-analysis

[Bug c++/86176] Wnull-dereference warning disappears with a call to std::cout on the line after

2018-06-18 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86176

--- Comment #3 from Jonathan Wakely  ---
No, because GCC is not a static analyser.

[Bug c++/86176] Wnull-dereference warning disappears with a call to std::cout on the line after

2018-06-18 Thread jg at jguk dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86176

--- Comment #2 from Jonny Grant  ---
I wonder, is there a way to configure GCC to perform in a way similar to static
analyser? GCC warnings are very useful.

[Bug c++/86176] Wnull-dereference warning disappears with a call to std::cout on the line after

2018-06-18 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86176

Richard Biener  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2018-06-18
 Ever confirmed|0   |1

--- Comment #1 from Richard Biener  ---
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.