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

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


2
0
Sign in
to vote
ID 640356 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 1/30/2011 2:14:23 PM
Access Restriction Public

Description

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;
} 
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)