------- Comment #5 from dodji at gcc dot gnu dot org 2009-05-16 16:39 ------- By the way, here what I think is happening.
During the parsing of template<> struct y<void> : public x<void> { typedef x<void>::type z; }; We detect that x<void>::type is a use of a typedef that is a member of the class template x. We then wrongly append x<void>::type to the representation of template<typename T> struct y so that we can perform access checks on the use of x<void>::type once we instantiate y<void>. Later, during the instantiation of template<typename T> struct y into y<int> we wrongly try to perform access checks of x<void>::type even if x<void>::type has no business with the instantiation of template<typename T> struct y; In short, the typedef use x<void>::type should be added (for access checking purposes) to the representation of the specialized template<> struct y<void>, not to the representation of the most general template<typename T> struct y. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40007