GCC complains about nested functions despite none being present

Jeffrey Walton noloader@gmail.com
Sun Jun 25 22:27:00 GMT 2017

On Sun, Jun 25, 2017 at 2:46 PM, Ian Lance Taylor via gcc-help
<gcc-help@gcc.gnu.org> wrote:
> On Sun, Jun 25, 2017 at 11:41 AM, Maxim Blinov <maxim.a.blinov@gmail.com> wrote:
>> However, what is a static chain pointer exactly? After some reading, I
>> understand it to be used for retrieving locals from the caller's
>> frame, but how would this functionality be relevant to C?
> GCC supports nested functions as a C extension.
> https://gcc.gnu.org/onlinedocs/gcc-7.1.0/gcc/Nested-Functions.html#Nested-Functions
> I don't know why you get the error in code that doesn't use static
> functions.  It may be a minor bug--an unnecessary call to to the
> static_chain hook.

It may be more than a minor bug. The trampoline often requires an
executable stack, and that's usually a SDLC violation.

Maybe worse, you could silently lose NX-stacks because GCC does not
warn about it. To produce a warning, you need -Wtrampoline, which is
off by default. I know very few people who configure with the warning
to detect loss of NX-stacks.

And of course, if you don't care about SDLCs, then everything is fine.


More information about the Gcc-help mailing list