Search

decltype does not seem to work ok with operator, expressions by Bengt Gustafsson

Closed
as Fixed Help for as Fixed

2
0
Sign in
to vote
Type: Bug
ID: 640356
Opened: 1/30/2011 2:14:23 PM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
decltype is supposed to yield the type of its parameter. A comma expression is supposed to have the type of its right hand operand. In the example below all but c2 are false when compiled with VS2010. When it comes to c1 this is weird to me but clearly standard compliant, while for c4 and c5 I'm not sure... is this correct, or is it a compiler bug? Sadly enough, my real code relied on is_reference to return true in at least for c4.

Two last lines of function compiles as expected which shows that the actual evaluation of the comma expression works.

I posted this on stackoverflow and the comments I got agreed with my thinking that this is actually a bug.

#include <type_traits>
void comma()
{
int str = 1;
bool c1 = std::is_reference<decltype(str)>::value;
bool c2 = std::is_reference<decltype((str))>::value;
bool c3 = std::is_reference<decltype((str, str))>::value;
bool c4 = std::is_reference<decltype((str, str))>::value;
bool c5 = std::is_reference<decltype((str, (str)))>::value;

int& s2 = (1, str);
s2 = 2;
}
Details (expand)

Visual Studio/Silverlight/Tooling version

Visual Studio 2010

What category (if any) best represents this feedback?

Compatibility

Steps to reproduce

Compile code. Check valued for c4 and c5 when code has run.

Product Language

English

Operating System

Windows 7

Operating System Language

English

Actual results

c4==false , c5==false

Expected results

c4 == true, c5 == true
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 3/28/2011 at 10:18 AM
Hi Bengt,

Thanks for reporting this issue to us. We have fixed it and that fix should be available in the next major release of Visual Studio.

Jamie Eckman
Visual C++ Team
Posted by Microsoft on 1/30/2011 at 7:42 PM
Thanks for your feedback.
We are routing 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 1/30/2011 at 3:01 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.