This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/81524] New: Bogus or missing warnings when dereferencing pointer to deallocated stack memory
- From: "fredrik dot hederstierna at securitas-direct dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 23 Jul 2017 15:28:10 +0000
- Subject: [Bug c/81524] New: Bogus or missing warnings when dereferencing pointer to deallocated stack memory
- Auto-submitted: auto-generated
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.hederstierna@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?