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: unassig...@gcc.gnu.org
        ReportedBy: fredrik.hederstie...@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.

Reply via email to