hello, the following program fails to correctly find the right overloaded global template function f(). clearly ::f() called within test::f() depends on a template parameter so lookup should be postponed to the point of instantiation which is not the case. if template <class X> void f(X& x, const char& y) is moved so that its definition appears before definition of class test, the output is correct. this problem seems to be there since gcc3.4
#include <string> #include <iostream> template <class X, class Y> void f(X& x, const Y& y) { std::cout << "global: " << x.id() << " " << y <<std::endl; } struct test { std::string id() const { return "test"; } template <class Y> void f(const Y& y) { ::f(*this,y); } }; template <class X> void f(X& x, const char& y) { std::cout << "global(char): " << x.id() << " " << y <<std::endl; } int main() { test it; it.f(2); it.f('a'); //doesn't call overloaded ::f(X&, const char&) } -- Summary: name lookup and partial ordering Product: gcc Version: 4.0.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: cerdeira at co dot sapo dot pt http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24594