Microsoft C++ compiler crash - by Duca Stefan

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.

Sign in
to vote
ID 725056 Comments
Status Closed Workarounds
Type Bug Repros 1
Opened 2/15/2012 6:51:40 AM
Access Restriction Public


Microsoft Visual Studio 2010
Version 10.0.40219.1 SP1Rel

The following C++ code leads to a compiler crash:

class RegisterData

	RegisterData(const std::string& name, std::function<bool()> fun )

RegisterData TestCrash("%TestCrash", []() -> bool

	catch (std::bad_cast&)


	return true;

int _tmain(int argc, _TCHAR* argv[])
	return 0;

1>  CompilerCrashTest.cpp
1>d:\users\stefan\projects\compilercrashtest\compilercrashtest\compilercrashtest.cpp(20): fatal error C1001: An internal error has occurred in the compiler.
1>  (compiler file 'msc1.cpp', line 1420)
1>   To work around this problem, try simplifying or changing the program near the locations listed above.
1>  Please choose the Technical Support command on the Visual C++ 
1>   Help menu, or open the Technical Support help file for more information

The issue seems to be due to the presence of the try/catch in the lambda body. If I comment out the try catch the crash dissapears.
Sign in to post a comment.
Posted by Duca Stefan on 2/17/2012 at 6:38 AM
Hi Ulzii,

Thank you for the answer and glad to hear that this is fixed. Is there any chance that the fix will be made available for VS 2010 (let's say via a ServicePack 2)? Or this will be available really only within the new VS 11 release?

Posted by Microsoft on 2/16/2012 at 6:43 PM
Hello Duca,

Thank you for reporting this bug. We've fixed this in the current in-development release of Visual C++. We'll make sure this scenario still compiles as we ship the next major release. I apologize for the inconvinience the bug is causing you.

Posted by MS-Moderator10 [Feedback Moderator] on 2/15/2012 at 10:44 PM
Thank you for submitting feedback on Visual Studio 2010 and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by MS-Moderator01 on 2/15/2012 at 7:44 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(
Posted by Duca Stefan on 2/15/2012 at 6:58 AM
At the simplest level the code below also has the same problem:

#include "stdafx.h"

auto fn = []()
    try    {    }
    catch (...)    { }

int _tmain(int argc, _TCHAR* argv[])
    return 0;

try/catch in lambdas at function scope does not lead to problems. try/catch in global scope lambdas do cause problems it would seem...