Search

Compile Error in globally scoped lambda with a for loop by LumenTelum

Closed
as Fixed Help for as Fixed

1
1
Sign in
to vote
Type: Bug
ID: 693671
Opened: 10/7/2011 5:00:22 PM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
0
Workaround(s)
0
User(s) can reproduce this bug
Creating a lambda at global scope will result in a compile error if the lambda includes a for loop.
Details (expand)

Visual Studio/Team Foundation Server/.NET Framework Tooling version

Visual Studio 2010 SP1

Steps to reproduce

Define the following lambda at global scope.
auto global_lambda = []{
    for(int i = 0; i < 100; i++)
    {
    }
};

Product Language

English

Operating System

Windows 7

Operating System Language

English

Actual results

Compilations results in the following errors:
1>w:\documents\visual studio 2010\projects\compilerbug\compilerbug.cpp(7): error C2143: syntax error : missing ')' before ';'
1>w:\documents\visual studio 2010\projects\compilerbug\compilerbug.cpp(7): error C2143: syntax error : missing ';' before ')'
1>w:\documents\visual studio 2010\projects\compilerbug\compilerbug.cpp(7): error C2143: syntax error : missing ';' before ')'
1>w:\documents\visual studio 2010\projects\compilerbug\compilerbug.cpp(7): error C2065: 'i' : undeclared identifier
1>w:\documents\visual studio 2010\projects\compilerbug\compilerbug.cpp(7): error C2065: 'i' : undeclared identifier
1>w:\documents\visual studio 2010\projects\compilerbug\compilerbug.cpp(7): error C2059: syntax error : ')'
1>w:\documents\visual studio 2010\projects\compilerbug\compilerbug.cpp(8): error C2143: syntax error : missing ';' before '{'

Expected results

The lambda should compile without error.
File Attachments
File Name Submitted By Submitted On File Size  
CompilerBug.zip 10/7/2011 3 KB
Sign in to post a comment.
Posted by Microsoft on 10/14/2011 at 5:26 PM
Thank you for reporting this issue to us. We're happy to report that it's already been fixed in the compiler and the fix will be available in the next release.

Tanveer Gani
Visual C++ Team
Posted by MS-Moderator08 [Feedback Moderator] on 10/10/2011 at 12:03 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 10/7/2011 at 5:43 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)
Sign in to post a workaround.