Search

Lambda's automagic ctor gets wrong signature (or call) when implicit and explicit capture is mixed. by Bengt Gustafsson

Closed
as Fixed Help for as Fixed

1
0
Sign in
to vote
Type: Bug
ID: 641032
Opened: 2/2/2011 2:23:13 PM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
In the code below the compiler complains about its own implicit ctor for the inner lambda not being matched to the call signature.

This somehow has to do with the implicit const added to the x ctor parameter of the outer lambda not being added when the ctor for the inner lambda is built...

A workaround exist: Make the outer lamdba mutable.

void func()
{
    int x;
    int y;
    [&, x]()->void {
        [&]() { x; y; };
    };
}
Details (expand)

Visual Studio/Silverlight/Tooling version

Visual Studio 2010

What category (if any) best represents this feedback?

Compatibility

Steps to reproduce

Compile code.

Product Language

English

Operating System

Windows 7

Operating System Language

English

Actual results

c:\privat\src\ru\bug9.cpp(7): error C2665: '`anonymous-namespace'::<lambda1>::<lambda1>' : none of the 2 overloads could convert all the argument types
         c:\privat\src\ru\bug9.cpp(7): could be '`anonymous-namespace'::<lambda1>::(int &,int &)'
         while trying to match the argument list '(const int, int)'

Expected results

no errors.
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 6/13/2011 at 9:33 AM
Hi Bengt:
    A fix for this issue has been checked into the compiler sources. The fix should show up in the next release of Visual C++.

Xiang Fan
Visual C++ Team
Posted by Microsoft on 2/2/2011 at 3: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.