Search

Visual C++: Argument Forwarding Bugs in std::bind Function Callers by Timothy003

Closed
as Fixed Help for as Fixed

1
0
Sign in
to vote
Type: Bug
ID: 640961
Opened: 2/2/2011 8:10:07 AM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
std::bind does not forward arguments correctly when calling functions and member functions.
Details (expand)

Visual Studio/Silverlight/Tooling version

Visual Studio 2010

What category (if any) best represents this feedback?

Compatibility

Steps to reproduce

#include <utility>
#include <functional>

using std::bind;

void f(int &&)
{
}

struct A
{
    void f(int &&)
    {
    }
};

int &&g(int &x)
{
    return std::move(x);
}

int main()
{
    // case 1 - bind function
    bind(f, bind(g, int()))();    // compiles, but incorrect result
    // case 2 - bind member function
    bind(&A::f, A(), bind(g, int()))();    // error
}

Product Language

English

Operating System

Windows 7

Operating System Language

English

Actual results

on case 1:
calls f(int &&) with a reference to an uninitialized variable
on case 2:
c:\program files (x86)\microsoft visual studio 10.0\vc\include\xxpmfcaller(33): error C2664: 'void (int &&)' : cannot convert parameter 1 from 'int' to 'int &&'
         You cannot bind an lvalue to an rvalue reference

Expected results

No errors. Implementation should forward the result of the nested bind as type 'int &&' for both cases, with a value of 'int()'.
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 6/28/2011 at 6:03 PM
Hi,

Thanks for reporting this bug. We've fixed it, and the fix will be available in VC11.

If you have any further questions, feel free to E-mail me at stl@microsoft.com .

Stephan T. Lavavej
Visual C++ Libraries Developer
Posted by Microsoft on 2/2/2011 at 5:38 PM
Thanks for your feedback.

We are rerouting 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 8:58 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.