Home Dashboard Directory Help

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


 as Fixed Help for as Fixed

Sign in
to vote
Type: Bug
ID: 706814
Opened: 11/21/2011 3:55:10 AM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
User(s) can reproduce this bug


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 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)
Sign in to post a workaround.
File Name Submitted By Submitted On File Size  
EnumTest.zip 11/21/2011 5 KB