Home Dashboard Directory Help

Bug in lambda expressions by Андрей Алифанов


 as Fixed Help for as Fixed

Sign in
to vote
Type: Bug
ID: 694857
Opened: 10/13/2011 8:47:33 PM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
User(s) can reproduce this bug


Why compiler cant't compile this code?

template <class T>
void f()
    ([&]() { typename T::type x; })();

struct X
    typedef int type;

int main()

When I try to compile it, I get the next diagnostic:

Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.

test.cpp(4) : error C2899: typename cannot be used outside a template declaration
test.cpp(4) : error C2653: 'T' : is not a class or namespace name
test.cpp(4) : error C2065: 'type' : undeclared identifier
test.cpp(4) : error C2146: syntax error : missing ';' before identifier 'x'
test.cpp(4) : error C2065: 'x' : undeclared identifier

This code is correct as I know and Intel C++ 12.1 proves it.

But VC++ 10.0 SP1 compiles this code:

template <class T>
    void f()
    ([&]() { typedef T TT; TT::type x; })();

I think this is not correct because of typename keyword lack before TT::type
Sign in to post a comment.
Posted by Microsoft on 11/3/2011 at 9:27 AM
Hi: this issue has been fixed. The fix should show up in a future release of Visual C++.

Thank you for reporting the issue.

Jonathan Caves
Visual C++ Compiler Team
Posted by MS-Moderator09 [Feedback Moderator] on 10/14/2011 at 2:44 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 review. We will contact you if we require any additional information.
Posted by MS-Moderator01 on 10/13/2011 at 9:45 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.