Bug 56135 - [c++11] this incorrectly captured as null in template member function
Summary: [c++11] this incorrectly captured as null in template member function
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.2
: P3 normal
Target Milestone: 4.7.3
Assignee: Jason Merrill
URL:
Keywords:
Depends on:
Blocks: lambdas
  Show dependency treegraph
 
Reported: 2013-01-29 02:19 UTC by Jacek Sieka
Modified: 2013-02-15 18:35 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-01-29 00:00:00


Attachments
Test case showing broken capture of this (233 bytes, text/x-c++src)
2013-01-29 02:19 UTC, Jacek Sieka
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jacek Sieka 2013-01-29 02:19:17 UTC
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.
Comment 1 Paolo Carlini 2013-01-29 10:56:02 UTC
Probably Dup of PR54403.
Comment 2 Jason Merrill 2013-02-13 17:56:11 UTC
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
Comment 3 Paolo Carlini 2013-02-14 23:29:27 UTC
Fixed for 4.8.0.
Comment 4 Jason Merrill 2013-02-15 18:31:41 UTC
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
Comment 5 Paolo Carlini 2013-02-15 18:35:34 UTC
... and 4.7.3.