https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100362
--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> --- If we remove the unneeded 'this' capture, then it's a rejects-valid bug: template <class> struct Qux { struct A { } a_; void AsyncOp() { [](auto) { struct Grault : decltype(a_) {}; Grault ptr; }(0); } }; void corge() { Qux<int> qux; qux.AsyncOp(); } <stdin>: In instantiation of ‘struct Qux<int>::AsyncOp()::<lambda(auto:1)>::Grault’: <stdin>:11:14: required from ‘Qux<int>::AsyncOp()::<lambda(auto:1)> [with auto:1 = int]’ <stdin>:12:6: required from ‘void Qux< <template-parameter-1-1> >::AsyncOp() [with <template-parameter-1-1> = int]’ <stdin>:18:14: required from here <stdin>:10:32: error: invalid use of non-static data member ‘Qux<int>::a_’ <stdin>:10:32: error: ‘Qux<int>::A Qux<int>::a_’ is inaccessible within this context <stdin>:6:16: note: declared here