fatal error C1001 in visual studio 2012 compiler with lambda function in struct initializer list - by William Dang

Status : 

 


1
0
Sign in
to vote
ID 775758 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 1/4/2013 12:47:26 AM
Access Restriction Public

Description

struct TestStruct {
    int m1;
    int (*m2)(int);
};

int main(int argc, char const *argv[]){
   static TestStruct ts = {
    42,
    [](int var)->int{
     int something = var * 42;
     return something;
    }
  };

    return 0;
}

/*
 Conditions for  crash:
 - a struct (TestStruct) containing at least two members:
    1. anything (m1)
    2. function pointer (m2)
 - struct's function pointer member must be preceded by another member
 - declared struct variable (ts) must use static storage
 - struct variable must be initialized via struct initializer as opposed to assigning members individually
 - lambda must be defined in the struct initializer list as opposed to declaring a named lambda and placing it in the struct initializer list
 - lambda body must contain a variable that is declared and initialized together as opposed to declaring and initializing separately
*/
Sign in to post a comment.
Posted by Microsoft on 2/5/2013 at 1:27 PM
Hi:
    Thanks for reporting the issue.
    A fix for this issue has been checked into the compiler sources. The fix should show up in the next release of Visual C++.

Xiang Fan
Visual C++ Team
Posted by Microsoft on 1/4/2013 at 2:04 AM
Thank you for submitting feedback on Visual Studio 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 Microsoft on 1/4/2013 at 12:50 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)