This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Warn if making external references to local stack memory?


>> 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.
>
> Thanks.  I would encourage you to file an enhancement request at
> http://gcc.gnu.org/bugzilla/ .
>
>> 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?
>
> Since these sorts of errors can occur in both C and C++ it would be
> slightly better to use a common framework for them if possible, perhaps
> in c-family/c-common.c.  I haven't really thought about what is required
> here, though.

I've added the following enhancement request to bugzilla

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52923
"Bug?52923 - Warn if making external references to local stack memory"

Thanks & Best Regards
Fredrik


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]