Search

Absence of conversion operator-function to pointer to function in lambda-expression. by Сыроежка

Closed
as Fixed Help for as Fixed

1
0
Sign in
to vote
Type: Bug
ID: 724616
Opened: 2/12/2012 12:19:56 PM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
0
Workaround(s)
0
User(s) can reproduce this bug
According to the paragraph 5.1.2 "Lambda expressions" p.6 of the C++ 2011 Standard "The closure type for a lambda-expression with no lambda-capture has a public non-virtual non-explicit const conversion function to pointer to function having the same parameter and return types as the closure type’s function call operator. The value returned by this conversion function shall be the address of a function that, when invoked, has the same effect as invoking the closure type’s function call operator."
However the VC++ 2010 compiler issues error "error C2440: инициализация: невозможно преобразовать "`anonymous-namespace'::<lambda0>" в "void (__cdecl *)(int)"
Для выполнения данного преобразования нет доступного оператора преобразования, определенного пользователем, или вызов оператора невозможен"
Details (expand)

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

Visual Studio 2010 SP1

Steps to reproduce

This code is not compiled by VC++ 2010
#include <iostream>

int main()
{
void ( *f )( int ) = []( int x ) { std::cout << x << " "; };
f( 10 );
return ( 0 );

Product Language

Russian

Operating System

Windows 7

Operating System Language

Russian

Actual results

Compilation error

error C2440: инициализация: невозможно преобразовать "`anonymous-namespace'::<lambda0>" в "void (__cdecl *)(int)"
Для выполнения данного преобразования нет доступного оператора преобразования, определенного пользователем, или вызов оператора невозможен

Expected results

The code shall be compiled successfully and the lambda expression shall be converted to function pointer.
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 2/13/2012 at 12:52 PM
Thank you for reporting this issue to Microsoft. We're glad to say that it's already been fixed and the fix will be available in the next release of the compiler.

Tanveer Gani
Visual C++ Team
Posted by MS-Moderator08 [Feedback Moderator] on 2/12/2012 at 10:20 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/12/2012 at 12:41 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.