https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71069
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |diagnostic Status|UNCONFIRMED |NEW Last reconfirmed| |2016-07-06 CC| |msebor at gcc dot gnu.org Ever confirmed|0 |1 Severity|normal |enhancement --- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> --- I agree that diagnosing these problems at compile time would be ideal, but it's not always possible (in fact, I suspect it rarely is: only when GCC can prove that the reference is initialized by dereferencing a null pointer). What I think could help, though, is warning for the test that GCC eliminates based on the assumption that the reference address will never be null. Unfortunately, to do that in any but the most trivial cases, the warning would need to rely on optimization. Still, I'll confirm this as an enhancement request to extend -Waddress to help highlight at least some of these problems.