------- Comment #7 from schaub-johannes at web dot de 2010-03-08 23:41 ------- I've digged this up from an early draft ('96: http://ra.dkuug.dk/JTC1/SC22/WG21/docs/wp/txt/jun96/body.txt), '98 and '03). Each has different rules. In fact, C++98 would accept comment#3's code.
- '96pre-standard said that: if a base class is dependent, this scope is not examined by lookup (of any kind) until the class is instantiated. However, if a base class is a template parameter, then the names declared in it do not hide names from an enclosing scopes. (So, if we inherit from "T", we first look in the "enclosing" scopes and if we found nothing, we look in dependent base classes). - '98 said that: if a base class is dependent and declares a name, that name may not hide a name from the enclosing scopes. I don't think that A::foo is considered to be in an enclosing scope of HasFoo, so C++98 would also reject my code, i think. So C++98 just did away with the difference of inheriting a template-parameter and the general case of dependent bases for the hiding stuff. - '03 says that: Unqualified namelookup will not consider dependent bases - even not during instantiation. This was done by DR213: http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#213 . John Spicer sums it up: `What I thought the rule was is, "If a base class is a dependent type a member of that class is not found by unqualified lookup".`. According to Erwin Unruh in that DR, unqualified lookup at the definition context can't find members in dependent base classes "because you don't know what base class you have.". I am in the impression that since lookup for dependent names is post-poned until the actual template arguments are known, we will indeed be able to descend into dependent base classes when doing lookup in the definition context, since we know the exact types of these bases by then (and this seems to be what GCC is doing currently, actually). -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43282