Home Dashboard Directory Help
Search

Bug with operator overloading and nested lambdas by Bengt Gustafsson


Status: 

Closed
 as Fixed Help for as Fixed


1
0
Sign in
to vote
Type: Bug
ID: 634671
Opened: 1/5/2011 1:24:48 AM
Access Restriction: Public
0
Workaround(s)
view
0
User(s) can reproduce this bug

Description

The code below does not compile. The error is on the messy line of the second half of the function. The exact same messy line in the first half compiles. The only difference is that in the second half the enclosing compound statement is a lambda body while in the first half it is just a nested block.

Given the nature of the error message (and the newness of the lambda implementation) I would deduce that this is a compiler bug relating to the nesting of the lambdas. I can't see any reason that the line would compile differently inside an outer lambda, as no new names or operators are introduced.


class Class {
public:
    template<typename F> void operator<<(const F& func) {}
};

template<typename R> R& operator-(const char* lhs, R& rhs) { return rhs; }

void click(Class& button)
{
}


void test()
{
    {
        Class b;
        b << click;
        "Test" - b << click;

     "Test"-[&]()->Class& { return *new Class; }() << click;
    };

    [&]() {
        Class b;
        b << click;
        "Test" - b << click;

     "Test"-[&]()->Class& { return *new Class; }() << click;
    };
}

Note that this code seems rather unuseful, but I have of course boilt it down from a more fleshed out example that actually does make sense.
Details
Sign in to post a comment.
Posted by Microsoft on 2/4/2011 at 1:20 PM
Hi:
    The root cause of the issue is the same as http://connect.microsoft.com/VisualStudio/feedback/details/634688.
    We have fixed that one recently.

Xiang Fan
Visual C++ Compiler Team
Posted by Microsoft on 1/18/2011 at 3:37 PM
Hello,

Thanks for reporting this issue. We do have lots of issues with nested lambdas in our compiler, and we are working on improving them for next release. The standard did make some late changes around nested lambdas which contributed greatly in having a low quality in this specific area of the compiler.

Thanks,
Ulzii Luvsanbat
Windows C++ Team
Posted by Bengt Gustafsson on 1/5/2011 at 5:47 AM
Note: This is probably caused by the bug I reported later as: 634688
Posted by Microsoft on 1/5/2011 at 1:26 AM
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.