https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96485
Bug ID: 96485 Summary: Lambda parsing regression in GCCs 9 and onwards Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: s_gccbugzilla at nedprod dot com Target Milestone: --- As the repro at https://godbolt.org/z/Gvx75e shows, the following code compiled fine in GCCs up to and including GCC 8.3: ``` void test() { []() #if 1 __attribute__((no_sanitize_undefined)) #endif ->int { return 0; }; } ``` >From GCC 9 onwards, we get: ``` <source>: In lambda function: <source>:7:5: error: expected '{' before '->' token 7 | ->int { | ^~ <source>: In function 'void test()': <source>:7:5: error: base operand of '->' has non-pointer type 'test()::<lambda()>' <source>:7:7: error: expected unqualified-id before 'int' 7 | ->int { | ^~~ Compiler returned: 1 ``` This code compiles fine in clang, incidentally, though it doesn't recognise the attribute.