http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58896
Bug ID: 58896 Summary: Incorrect handling of a private nested type of a template specialization in the main template Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ville.voutilainen at gmail dot com This code compiles without any problem: template<typename> class Obj; template<> class Obj<void> { struct secret{}; }; template<typename T> class Obj { Obj<void>::secret m; }; int main() { Obj<int> obj; } It's as if the main template somehow manages to be a friend of its specialization. When the nested name is a typedef, it's diagnosed: template<typename> class Obj; template<> class Obj<void> { typedef int secret; }; template<typename T> class Obj { Obj<void>::secret m; }; int main() { Obj<int> obj; } This results in edoceo.cpp: In instantiation of ‘class Obj<int>’: edoceo.cpp:11:12: required from here edoceo.cpp:3:15: error: ‘typedef int Obj<void>::secret’ is private typedef int secret; ^ edoceo.cpp:6:14: error: within this context Obj<void>::secret m; ^