Visual C++ does not handle based enums correctly - by Alf P. Steinbach, except MS doesn't accept it

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.


3
0
Sign in
to vote
ID 699236 Comments
Status Closed Workarounds
Type Bug Repros 3
Opened 11/4/2011 9:31:43 PM
Access Restriction Public
Moderator Decision Sent to Engineering Team for consideration

Description

Up to and including Visual C++ 11 (I only have the preview of that compiler) the following code fails to compile:

#ifdef _MSC_VER
#   pragma warning( disable: 4480 )     // enum base as "nonstandard extension"
#endif
enum ShouldBeFine: char { hola };

enum Choice { a, b, c };

template< Choice c > struct Traits;

template<> struct Traits<a> { typedef char Type; };
template<> struct Traits<b> { typedef wchar_t Type; };
template<> struct Traits<c> { typedef long Type; };

template< Choice c >
struct Blah
{
    enum X: typename Traits<c>::Type {};
};

int main()
{}
Sign in to post a comment.
Posted by Microsoft on 11/17/2011 at 8:07 PM
Hi: this issue has been fixed. The fix should show up in a future release of Visual C++.

Thank you for reporting the issue.

Jonathan Caves
Visual C++ Compiler Team
Posted by MS-Moderator09 [Feedback Moderator] on 11/6/2011 at 7:31 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 review. We will contact you if we require any additional information.
Posted by MS-Moderator01 on 11/6/2011 at 6:30 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)