https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81524
Bug ID: 81524 Summary: Bogus or missing warnings when dereferencing pointer to deallocated stack memory Product: gcc Version: 7.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: fredrik.hederstie...@securitas-direct.com Target Milestone: --- Created attachment 41814 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41814&action=edit test_deref_ptr_to_dealloc_stack_mem.c When dereferencing a pointer to deallocated stack memory sometimes warnings messages are missing or gives bogus information. See attached test example with 6 different cases. Some cases does give confusing message I think and some are missing. Tested with GCC 7.1 and flags: -Wnull-dereference -Wreturn-local-addr -Wuninitialized Could it be possible to differ between 'null' pointer and 'dangling' pointer? In pointer-to analysis it might be possible to in flow to see if pointer will point to deallocated stack frame memory and mark it as 'dangeling'? Now it seems to if ref missing it assume NULL and give null-pointer warning in some cases, which might be bogus?