http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54309
Bug #: 54309 Summary: type alias accessing class template enum type member fails Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: major Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: p...@preney.ca Created attachment 28046 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28046 Source code demonstrating the bug. This is easier to see not working than to describe. The code that does not work (i.e., "not ok: BUG" comment in the example) works if you replace the using type alias with a typedef instead though (which means that is a work-around for now). This bug was tested with these versions of GCC: g++ v4.7.0 g++ v4.8.0 (snapshot 20120812) The error message (from GCC v4.8): $ g++-4.8.0-alpha20120812 -std=c++11 gcc-cxx-bug.cxx gcc-cxx-bug.cxx: In instantiation of ‘void func() [with T = int]’: gcc-cxx-bug.cxx:25:13: required from here gcc-cxx-bug.cxx:15:24: error: no type named ‘Stuff’ in ‘using test = class Foo<T>’ typename test::Stuff b = test::Stuff::beta; // not ok: BUG ^ gcc-cxx-bug.cxx:15:24: error: no type named ‘Stuff’ in ‘using test = class Foo<T>’ gcc-cxx-bug.cxx:15:24: error: no type named ‘Stuff’ in ‘using test = class Foo<T>’ $ (I also tried this code with clang++ (v3.1) and it compiles successfully as expected.) It appears to only occur when a using type alias (i.e., the "test" alias in the example) is used to access a template class' member that is an enum type (i.e., "Foo<T>::Stuff" in the example) when the class template parameter is not hard-coded using the using type alias (i.e., Foo<T> is used but Foo<int> is okay). The code triggering the issue follows and is attached. template <typename T> class Foo { public: enum class Stuff { alpha, beta }; }; template <typename T> void func() { typename Foo<T>::Stuff a = Foo<T>::Stuff::alpha; // ok a = a; using test = Foo<T>; typename test::Stuff b = test::Stuff::beta; // not ok: BUG b = b; typedef Foo<T> test2; typename test2::Stuff c = test2::Stuff::beta; // ok c = c; } int main() { func<int>(); { Foo<int>::Stuff a = Foo<int>::Stuff::alpha; // ok a = a; using test = Foo<int>; typename test::Stuff b = test::Stuff::beta; // ok b = b; typedef Foo<int> test2; typename test2::Stuff c = test2::Stuff::beta; // ok c = c; } }