------- Comment #3 from mmitchel at gcc dot gnu dot org 2006-06-15 00:06 ------- The problem here is with the parser optimization by which the results of parsing a nested-name-specifier is cached, even if the parser backs up. Here, we consider that "class A<N>::B::C" might be a class-head. In that context, the dependent name A<N>::B should be resolved. Therefore, the saved version of the nested-name specifier is the class A<N>::B, rather than typename A<N>::B. Then, since this is not in fact a class-head, we back up and try again, parsing the construct as an elaborated-type-specifier. In that context, we should get the typename -- but do not, due to the caching.
However, in this case A<N>::B shouldn't really be permitted to refer to the class, even if it were part of a class-head, as we A<N> is not the same thing as the abstract uninstantiated A. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27665