Lambda-to-function-pointer conversion fails in nested lambdas. - by Dr Pizza

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


1
0
Sign in
to vote
ID 734303 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 3/29/2012 1:30:54 PM
Access Restriction Public
Moderator Decision Sent to Engineering Team for consideration

Description

VC++11 implements conversion from no-capture lambdas to function pointers, in accordance to the C++ specification. As an extension, it allows the conversion to use any calling convention, so that we can easily use lambdas with existing Win32 APIs.

However, there seem to be some problems with this. Nested lambdas do not appear to pick the calling convention correctly. They pick __cdecl even when I need __stdcall. My motivating example looked something like this:

CreateThread(nullptr, 0, [] (void*) -> DWORD {
    CreateThread(nullptr, 0, [] (void*) -> DWORD {
        return 0;
    }, nullptr, 0, nullptr);
    return 0;
}, nullptr, 0, nullptr);

The outer lambda converted correctly. The inner one did not.
Sign in to post a comment.
Posted by Microsoft on 4/20/2012 at 4:37 PM
Hello,

Thank you for reporting this bug. We've fixed it for current in-development compiler, which will be availabe in the next major release of VS, soon.

Thanks,
Ulzii Luvsanbat
Visual C++ Team
Posted by MS-Moderator08 [Feedback Moderator] on 3/29/2012 at 10:49 PM
Thank you for submitting feedback on Visual Studio 11 and .NET Framework. Your issue has been routed to the appropriate VS development team for review. We will contact you if we require any additional information.

Posted by MS-Moderator01 on 3/29/2012 at 1:54 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)