Home Dashboard Directory Help

std::function crashes when used in array on stack by Frank Rast


 as Fixed Help for as Fixed

Sign in
to vote
Type: Bug
ID: 734591
Opened: 3/30/2012 6:56:47 AM
Access Restriction: Public
User(s) can reproduce this bug


When the second array element ist constructed it corrupts the first array element.
Sign in to post a comment.
Posted by Frank Rast on 5/9/2012 at 2:33 AM
Thank you for the workaround. Glad to hear that it will be fixed in VC11. For us it is currently not possible to switch to VC11, because compiled binaries no longer run on Windows XP. I would appreciate a fix for VC10. If our customers spend money on one of our products and they find a bug, then we fix it as soon as possible and for free. This should be natural for Microsoft too.

Frank Rast
Posted by Microsoft on 5/8/2012 at 7:53 PM

Thanks for reporting this bug, especially with a simple test case. (The Connect team didn't assign this to the VC team until today.) This was a compiler bug involving lambdas, and it has already been fixed. The fix will be available in VC11 RTM (I am not sure whether it got into the VC11 Beta).

If you need a workaround for VC10, the compiler bug was triggered by having multiple lambdas in a single braced-init-list. That can be avoided by doing this:

auto lambda1 = []() { a = 1; };
auto lambda2 = []() { a = 2; int b = a; (void) b; };
function<void ()> arr[] = { lambda1, lambda2 };

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 5/8/2012 at 2:52 AM
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 Frank Rast on 4/28/2012 at 12:58 PM
One month later and all I have got is a roboter response. Do you really take feedback serious? Actually it would be not that hard to switch to gcc. We would miss Visual Studio but if you force us to leave...
Posted by MS-Moderator01 on 3/30/2012 at 7:53 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.
File Name Submitted By Submitted On File Size  
testlambda.cpp 3/30/2012 750 bytes