"sa...@hederstierna.com" <fred...@hederstierna.com> writes:

> 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.

Ian

Reply via email to