Inner lambda capture list can't see variable through auto-capture of outer lambda, thus rendering the name unknown to the inner capture list - by Bengt Gustafsson

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 641023 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 2/2/2011 1:49:07 PM
Access Restriction Public


In the below function x in the capture list of the inner lambda is deemed unknown. This is hopefully not standard compliant. In the draft document c3225, clause 5.1.2 paragraph 9 you can read: 

The reaching scope of a local
lambda expression is the set of enclosing scopes up to and including the innermost enclosing function and
its parameters. [ Note: this reaching scope includes any intervening lambda-expressions.

This must mean that x should be visible when the inner lambda starts. And in paragraph 10:

The identifiers in a capture-list are looked up using the usual rules for unqualified name lookup (3.4.1); each
such lookup shall find a variable with automatic storage duration declared in the reaching scope of the local
lambda expression.

Should mean that there is no special rules when checking for the names in the capture clause.

void func()
	int x;
	[&]()->void {
		[x]() {};
Sign in to post a comment.
Posted by Microsoft on 8/17/2011 at 11:18 AM
Hi: this issue has been fixed. The fix should show up in a future release of Visual C++.

Thank you for reporting the issue.

Jonathan Caves
Visual C++ Compiler Team
Posted by Microsoft on 2/2/2011 at 6:36 PM
Thanks for your feedback.
We are routing this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 2/2/2011 at 5:00 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(