switch statement with 64 bit enum gives compiler error - by Rolf Kristensen

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.

Sign in
to vote
ID 706814 Comments
Status Closed Workarounds
Type Bug Repros 2
Opened 11/21/2011 3:55:10 AM
Access Restriction Public


I define an enum and force the type to __int64

typedef enum MyEnum : __int64
	e1 = 0,
	e2 = 1,
	e3 = 4294967296, // 2^32
	e4 = 8589934592, // 2^33

The following code causes code analysis to fail with errors about "case value '0' already used":

	MyEnum value = e3;
	switch (static_cast<__int64>(value))
	case e1: break;
	case e2: break;
	case e3: break;
	case e4: break;
	default: break;

Also if I remove the cast to __int64 in the switch-statement, then I get errors about case constant too big for the type of the switch expression.
Sign in to post a comment.
Posted by Microsoft on 4/29/2014 at 12:24 PM
Thank you for reporting this issue. This issue has been fixed in Visual Studio 2013. You can install a trial version of Visual Studio 2013 with the fix from: http://go.microsoft.com/?linkid=9832436
Posted by MS-Moderator08 [Feedback Moderator] on 11/21/2011 at 6:54 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 11/21/2011 at 4:42 AM
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)