https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89990
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2019-04-08 CC| |msebor at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> --- I agree that this would be a very useful enhancement. The value of a pointer becomes indeterminate after the lifetime of the object to which it points has ended. Even reading such a pointer is undefined, never mind dereferencing it. GCC could use that to issue helpful diagnostics even in absence of any evidence that the pointer is dereferenced, such as in the modified example below: int foo (mytype *ptr) { if (!ptr) { ptr = &(mytype) { }; } bar (ptr); // undefined } This applies not just to compound literals but to all other objects, including auto, allocated, and thread local storage.