https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104798
Bug ID: 104798 Summary: Regression: [[gnu::always_inline]] ignored on lambda, no warning emitted Product: gcc Version: 11.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jstein27 at binghamton dot edu Target Milestone: --- GCC 8: always_inline works on lambdas with both the __attribute__ syntax and the attribute specifier sequence syntax. GCC 9: always_inline works on lambdas with the __attribute__ syntax but not the attribute specifier sequence syntax, a warning is emitted with -Wattributes. GCC 10, 11: always_inline works on lambdas with the __attribute__ syntax but not the attribute specifier sequence syntax, a warning is NOT emitted with -Wattributes. Originally noticed on Compiler Explorer, so unfortunately, I can't provide more details easily regarding how the compiler was compiled and so on. Compiler explorer link to play with: https://gcc.godbolt.org/z/cnqh3v5of Code snippet: #include <cstdio> #if USE_SCOPED static auto l1 = [](auto v) [[gnu::always_inline]] { printf("%d\n", v * 2); }; #else static auto l1 = [](auto v) __attribute__((always_inline)) { printf("%d\n", v * 2); }; #endif int main() { l1(1); }