Created attachment 29298 [details] Test case showing broken capture of this When creating a lambda function in a template member function, when capturing this using [=], this is not captured correctly when the lambda only calls another template member function reusing the outer template argument. Qualifying the call with this or not passing on the outer template argument solves the issue. In the attached code, I expect this to be captured in all 4 cases, but the "broken" captures null resulting in the print out: ./test (nil) 0x7fff1354f2af 0x7fff1354f2af 0x7fff1354f2af GDB shows the same - this has been captured but with null as value. clang 3.2 captures this as expected.
Probably Dup of PR54403.
Author: jason Date: Wed Feb 13 17:56:05 2013 New Revision: 196021 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=196021 Log: PR c++/56135 * pt.c (tsubst_copy_and_build): Don't forget any new captures that arose from use of dependent names. Added: trunk/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this8.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/pt.c
Fixed for 4.8.0.
Author: jason Date: Fri Feb 15 18:31:28 2013 New Revision: 196085 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=196085 Log: PR c++/56135 * pt.c (tsubst_copy_and_build): Don't forget any new captures that arose from use of dependent names. Added: branches/gcc-4_7-branch/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this8.C Modified: branches/gcc-4_7-branch/gcc/cp/ChangeLog branches/gcc-4_7-branch/gcc/cp/pt.c
... and 4.7.3.