Home Dashboard Directory Help
Search

Microsoft C++ compiler crash by Duca Stefan


Status: 

Closed
 as Fixed Help for as Fixed


3
0
Sign in
to vote
Type: Bug
ID: 725056
Opened: 2/15/2012 6:51:40 AM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
0
Workaround(s)
view
1
User(s) can reproduce this bug

Description

Microsoft Visual Studio 2010
Version 10.0.40219.1 SP1Rel

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

class RegisterData
{
public:

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

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

    }
    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.
Details
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?

Thanks,
Stefan
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.

Thanks,
Ulzii
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(http://support.microsoft.com)
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...
Sign in to post a workaround.