Home Dashboard Directory Help
Search

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: 

Closed
 as Fixed Help for as Fixed


2
0
Sign in
to vote
Type: Bug
ID: 641023
Opened: 2/2/2011 1:49:07 PM
Access Restriction: Public
0
Workaround(s)
view
0
User(s) can reproduce this bug

Description

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]() {};
    };
}
Details
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(http://support.microsoft.com)
Sign in to post a workaround.