------- Comment #2 from schaub-johannes at web dot de 2010-03-08 00:01 ------- The point is that the scope of the base class is not examined even during instantiation, so you cannot find the class member function and ADL finds A::foo instead. The Standard says at 14.6.2/3:
In the definition of a class template or a member of a class template, if a base class of the class template depends on a template-parameter, the base class scope is not examined during unqualified name lookup either at the point of definition of the class template or member *or during an instantiation of the class template or member*. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43282