Search

std::make_shared call error (c++) by moctob

Closed
as Fixed Help for as Fixed

1
0
Sign in
to vote
Type: Bug
ID: 739016
Opened: 4/26/2012 6:53:15 AM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
0
Workaround(s)
0
User(s) can reproduce this bug
Call to std::make_shared fails with C2664 compile time error.
Details (expand)

Visual Studio/Team Foundation Server/.NET Framework Tooling version

Visual Studio 2010 SP1

Steps to reproduce

Test program:

#include <memory>
using namespace std;

struct F {
    F(int s,void (*p)()) {}
};

struct F2 {
    F2()
    {
        auto s = 1;
        make_shared<F>(1,&func); //error
        make_shared<F>(s,&func); //ok
        make_shared<F>(1,&F2::func); //ok
    }
    static void func() {}
};

void main()
{
}

Product Language

English

Operating System

Windows 7

Operating System Language

English

Actual results

Compiler output: error C2664: 'std::tr1::shared_ptr<_Ty> std::tr1::make_shared<F,int,void(void)>(_Arg0 &&,_Arg1 (__cdecl &&))' : cannot convert parameter 2 from 'void (__cdecl *)(void)' to 'void (__cdecl &&)(void)'

Expected results

Program should compile cleanly.
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 4/27/2012 at 9:54 PM
Hi,

Thanks for reporting this bug. It has already been fixed, and the fix will be available in VC11 RTM.

I confirmed that this emits a compiler error with VC10 SP1, while it compiles successfully with my current build of VC11. Since make_shared<T>() is a plain vanilla perfect forwarder, and given the (bogus) text of the compiler error, I am certain that a compiler bug was responsible here, which has been fixed.

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 MS-Moderator07 [Feedback Moderator] on 4/26/2012 at 7:19 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 MS-Moderator01 on 4/26/2012 at 7:43 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.