https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65221
Bug ID: 65221 Summary: typedef-name identifier not resolved in static member instantiation Product: gcc Version: 4.9.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: pit at shgn dot de Consider the following minimal example: template< typename A > struct X { using this_type = X<A>; // typedef X<A> this_type; static this_type inst; }; template< typename A > X<A> X<A>::inst; g++ 4.9.1 (Debian 4.9.1-19) produces the following error: $ g++ --std=c++11 -c test.cpp test.cpp:10:12: error: conflicting declaration ‘X<A> X<A>::inst’ X<A> X<A>::inst; ^ test.cpp:6:20: note: previous declaration as ‘X<A>::this_type X<A>::inst’ static this_type inst; ^ test.cpp:10:12: error: declaration of ‘X<A>::this_type X<A>::inst’ outside of class is not definition [-fpermissive] X<A> X<A>::inst; I expected the compiler to resolve the typedef-name from the alias-declaration when instantiating the static member. If we use this_type instead of the type directly: template< typename A > const typename X<A>::this_type X<A>::inst; the code compiles again. I assume that gcc is unable to map X<A> to the alias-declaration this_type. Commenting out the alias declaration and using the typedef line solves the problem. The standard however states in §7.1.3 (2): A typedef-name can also be introduced by an alias-declaration. The identifier following the using keyword becomes a typedef-name and the optional attribute-specifier-seq following the identifier appertains to that typedef-name. It has the same semantics as if it were introduced by the typedef specifier. In particular, it does not define a new type and it shall not appear in the type-id.