http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50471
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-09-21 10:19:21 UTC --- The name lookup is delayed until instantiation, however [temp.dep.candidate] says that the qualified lookup in g1 only finds declarations visible at the point of definition of g1: For a function call that depends on a template parameter, the candidate functions are found using the usual lookup rules (3.4.1, 3.4.2, 3.4.3) except that: — For the part of the lookup using unqualified name lookup (3.4.1) or qualified name lookup (3.4.3), only function declarations from the template definition context are found. — For the part of the lookup using associated namespaces (3.4.2), only function declarations found in either the template definition context or the template instantiation context are found.