https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81998
Bug ID: 81998 Summary: [c++14] lambda: name from init-capture not visible in lambda-declarator Product: gcc Version: 7.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: aschepler at gmail dot com Target Milestone: --- g++ 7.2.0 rejects this well-formed minimal code, whether using -std=c++14 or -std=c++1z: void f() { [x=2] (decltype(x)) {}; } Errors: main.cpp: In function 'void f()': main.cpp:2:20: error: 'x' was not declared in this scope [x=2](decltype(x)) {}; ^ main.cpp:2:20: error: 'x' was not declared in this scope C++14 [expr.prim.lambda]/11 says: "Within the lambda-expressions lambda-declarator and compound-statement, the identifier in the init-capture hides any declaration of the same name in scopes enclosing the lambda-expression." This implies the identifier ("x") from the init-capture ("x=2") should be in scope within the lambda-declarator ("(decltype(x))").