https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88088

--- Comment #19 from Mark Wielaard <mark at gcc dot gnu.org> ---
I think we are just talking past each other because we don't fully agree when
the warning should trigger and whether it is (trivial and/or) desirable to
avoid that specific corner case.

We do agree that nested functions are a useful C language extension and I am
using them extensively in my own code. The only corner case I would avoid is
when taking a nested function pointer escapes the current lexical context and
when calling that function pointer would need access to some lexical context
variables (because it will generate something that isn't a real simple function
pointer and it is hard to reason about when calling it is safe). Which is
precisely when -Wtrampolines triggers whenever that requires creating an
executable trampoline on the stack. IMHO it is easy to rewrite any code that
does that to pass around the bare function pointer plus context, which is what
I showed in my example (indeed by rewriting h also). You argue that this would
only be an issue if the stack was non-executable by default already.

I am fine with only triggering the warning with -Wall when otherwise the stack
would silently be marked as executable. The only problem is that there
currently is no target macro that can easily be used to tell whether or not a
target has the stack non-executable by default. So we would have to introduce
that.

Reply via email to