C++ - fatal error C1001 when using static local variable with non-trivial constructor in static local lambda - by __xeo

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 715680 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 12/27/2011 10:24:26 PM
Access Restriction Public
Moderator Decision Sent to Engineering Team for consideration

Description

The following snippet triggers an internal compiler error when the static local variable 'n' has a non-trivial constructor.

struct nontrivial{
    nontrivial(){}
};

int main(){
    static auto ICE = []()->int{
        static nontrivial n; // comment out to resolve error
        return 0;
    };
}

If the static local variable is changed to a type that has a trivial constructor, or if the lambda is changed to non-static, the compilation succeeds as expected.
Sign in to post a comment.
Posted by __xeo on 12/29/2011 at 5:57 PM
That's... very interesting, that a simple additional static local variable with a trivial constructor fixes it. Thanks!
Posted by Xiang [MSFT] on 12/29/2011 at 4:25 PM
Hi Philipp:
    A fix for this issue has been checked into the compiler sources. The fix should show up in the next release of Visual C++.
    Here is one of the possible workaround:

struct nontrivial{
    nontrivial(){}
};

int main(){
    static auto ICE = []()->int{
        static nontrivial n; // comment out to resolve error
        static int i = 0; // workaround
        return 0;
    };
}

Xiang Fan
Visual C++ Team
Posted by MS-Moderator08 [Feedback Moderator] on 12/28/2011 at 1:06 AM
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 12/27/2011 at 10:42 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)