[Bug c/52923] New: Warn if making external references to local stack memory
fredrik.hederstierna@securitas-direct.com
gcc-bugzilla@gcc.gnu.org
Tue Apr 10 07:40:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52923
Bug #: 52923
Summary: Warn if making external references to local stack
memory
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: fredrik.hederstierna@securitas-direct.com
Created attachment 27123
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27123
Example code with functions returning with stack memory refs bugs.
GCC does warn if returning a pointer to a local variable (stack memory).
But there are alot of more cases where GCC could possibly warn,
eg. when references are made to local variables or stack memory.
See this attached example code.
GCC warns for first case, but not the others.
I think all cases can be considered program bugs,
and could trigger a compiler warning I think.
I've found out that the present warning is done in "c-typeck.c",
is this the right place to but additional warnings of this kind too?
Thanks & Best Regards
Fredrik Hederstierna
The example code file was compiled with "-O2 -W -Wall -Wextra"
for enabling as many warnings as possible.
More information about the Gcc-bugs
mailing list