Search

[Codename Milan] Brace-initialization fails in function argument list (C2275) by Vidar Hasfjord

Closed

1
0
Sign in
to vote
Type: Bug
ID: 778440
Opened: 2/3/2013 9:57:13 PM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
The use of brace-initialization to construct a temporary in a function argument list fails with the error C2275; "illegal use of this type as an expression".

Workaround: Use old-style constructor call syntax.
Details (expand)

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

Visual Studio 2012

Steps to reproduce

See test code at the CTP compiler site: http://rise4fun.com/Vcpp/OV

// This code fails on the Visual C++ Compiler Nov 2012 CTP with the error:
// C2275: 'S' : illegal use of this type as an expression

struct S {S();};
struct T {T(S);};

void foo(S);

void test()
{
T t {S{}}; // OK
foo (S{}); // Bug: 'S' : illegal use of this type as an expression.
foo (S()); // Workaround: Use old-style constructor call syntax.
}

Product Language

English

Operating System

Windows 7

Operating System Language

English

Actual results

--\testvc.cpp(12) : error C2275: 'S' : illegal use of this type as an expression
        --\testvc.cpp(4) : see declaration of 'S'
--\testvc.cpp(12) : error C2143: syntax error : missing ')' before '{'
--\testvc.cpp(12) : error C2143: syntax error : missing ';' before '{'
--\testvc.cpp(12) : error C2059: syntax error : ')'

Expected results

No errors.
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 2/4/2013 at 10:46 AM
Hi Vidar:
    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 2/4/2013 at 1:24 AM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.

Posted by Microsoft on 2/4/2013 at 1:24 AM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.

Posted by Microsoft on 2/3/2013 at 10:51 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.