http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53815
Bug #: 53815 Summary: Explicit specialization of member enumeration of a class template Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: minor Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: pot...@mac.com C++11 quietly added a bullet point to the middle of the list of things that can be explicitly specialized (14.7.3/1 [templ.expl.spec]): - member enumeration of a class template So, this should compile: template <class x> struct Foo { int getX(x *p) { return(0); } enum E12 { a }; }; template <> int Foo<int>::getX(int*) { return(-15); } template <> enum Foo<int>::E12 { a, b, c }; It fails with "redeclaration of ‘Foo<int>::E12 Foo<int>::a’". Deleting "a" from the primary template results in "enumerator value 2 is too large for underlying type ‘unsigned int’". Adding an explicit underlying type of "int" to the specialization results in "underlying type mismatch in enum ‘enum Foo<int>::E12’". Then, adding the same underlying type to the primary template results in successful compilation. The enumerators of the specialization can be accessed from outside the class scope, but the enumerators of the hidden primary template are visible as well. The feature is rather bizarre, IMHO. This was caught by a StackOverflow user, although it's not clear he's even aware of C++11 but may have just always expected it to be legal. http://stackoverflow.com/q/11271553/153285