https://gcc.gnu.org/bugzilla/show_bug.cgi?id=16351
--- Comment #50 from Martin Sebor <msebor at gcc dot gnu.org> --- Yes, -Wnull-dereference is only in GCC 6 and later. -Wnonnull is in 5 and prior but it does only a superficial job of checking (it only detects null pointer constants). in GCC 7, -Wnonnull does a better job (but it's still far from perfect). Null pointer checking (and everything else) is always done per function. The challenge isn't in implementing it but rather in striking the right balance between the stages of compilation at which the checking is done. When done early early we may miss instances that could be exposed by later stages (optimizations). When done late we start flagging instances introduced by the earlier transformations that didn't appear in the original source code (and that may never be executed). It's a delicate balance between false negatives and false positives.