https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100686
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Component|middle-end |c++ --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- Likely nested functions (aka lambdas in this case) do not inherit attributes (and in this case in particular optimize attributes) from the containing function. That might be by design and correct, using the #pragma variant should result in more obvious behavior here (I hope ;)). So I'm not sure if this is a bug, esp. in the context of C nested functions, but of course the C++ FE could decide it is and apply select attributes also to lambdas contained in a function.