https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121443
Bug ID: 121443 Summary: GCC rejects valid lambda with local struct constructor in default argument Product: gcc Version: 16.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jirehguo at tju dot edu.cn Target Milestone: --- GCC rejects following code, which is accepted by Clang and MSVC. Reproducer: https://godbolt.org/z/EWjjvdfrh The same lambda, when used within a function body (e.g., main), is accepted without error. Flags: -std=c++23 Code: ``` int g(int i = [] { struct Node { int value; Node(int val) : value(val) {} }; Node node1(45); return node1.value; }()) { return i; } int main() { return g(); } ``` Output: ``` <source>: In lambda function: <source>:4:10: error: expected unqualified-id before 'int' 4 | Node(int val) : value(val) {} | ^~~ <source>:4:10: error: expected ')' before 'int' 4 | Node(int val) : value(val) {} | ~^~~ | ) Compiler returned: 1 ```