Stack Exchange
Is Visual C++ correct when it refuses this template-"dependent" based enum?
Code:
#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()
{} 

Only after a Herculean effort to file a bug report with Microsoft, did it occur to me that maybe Visual C++ is correct to refuse it, and g++, which compiles the above fine, is maybe wrong?
EDIT Details: the code fails to compile with Visual C++ 10.0 and with the preview of Visual C++ 11.0. Those compilers spit out some rambling error avalanche beginning with an alleged syntax error. The code compiles fine with MinGW g++ 4.4.1. Dani reports that it compiles fine with CLang. Unfortunately Comeau Online does not support this language feature, so it can't be decided in the way we often did for C++98, just give the code to Comeau.

Is ShouldBeFine just there to illustrate that typed enums compile?

If I am reading the grammar correctly, you are correct in that this should compile.  enum-base is : type-specifier-seq, and type-specifier-seq seems to include pretty much any type name you can think of, including typename Traits<c>::Type. And all three specializations result in Type being integral, which is also required of the enum-base.  So That looks kosher to me.

Strongly-typed enums are officially supported in the forthcoming Visual C++ 11 (not just partially supported).  See C++11 Features in Visual C++ 11

Huh, so it is.  That's one of the features I've been waiting for, so I'm surprised I overlooked that.

@AlfP.Steinbach: Yes, I tried it out.  I concur with Dennis's reading of the spec; this may well be a bug.  I don't see an obvious workaround either.

@JamesMcNellis: could you click on the "I can too" (the I can also reproduce it) button at the MS bug report?

This compiles fine in both clang and g++. In addition, template substitution should occur before the class and the enum inside is created, so it should not matter if its template dependent or not.

This has been fixed in the Visual C++ 11 Beta, released on February 29, 2012.
Note also that the warning you disabled--C4480--has also been fixed, so it is no longer incorrectly emitted in native C++ code when enum class is used.
