https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69673
Bug ID: 69673 Summary: Can't pass members in lambda capture list Product: gcc Version: 5.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: petschy at gmail dot com Target Milestone: --- struct A { int i; }; void foo(A& a) { auto l = [&a.i]() { }; } void bar(A& a) { auto& i = a.i; auto l = [&i]() { }; } void baz() { A a; auto l = [&a.i]() { }; } ---8<---8<---8<--- Only bar() compiles, the other two functions fail : g++-5.3.1 -std=c++11 20160204-lambda.cpp error: expected ‘,’ before ‘.’ token auto l = [&a.i]() { }; ^ Every gcc version I tried failed: 4.7.4, 4.8.4, 4.9.2, 5.3.1, 6.0.0 g++-5.3.1 -v Using built-in specs. COLLECT_GCC=g++-5.3.1 COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/5.3.1/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../configure --enable-languages=c,c++ --disable-multilib --program-suffix=-5.3.1 --with-build-config=my-bootstrap-O3-native Thread model: posix gcc version 5.3.1 20160204 (GCC) Regards, Peter