https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98646
--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> --- I don't see how either TREE_NO_WARNING or some magic call would help. Because the user can also write: // PR c++/98646 // { dg-do compile } // { dg-options "-Wnonnull" } struct B { void foo (); }; struct D : B { void show (); }; void D::show () { constexpr D *p = nullptr; if (p) p->foo (); } and that also warns and IMNSHO should not. We should warn for: struct B { void foo (); }; struct D : B { void show (); }; void D::show () { constexpr D *p = nullptr; p->foo (); } So, the problem is IMHO that the warning about passing NULL to this is misplaced, it shouldn't be done in the FEs, but later when there was at least some chance of dead code removal.