$ cat t.cc #include <cstdio> using namespace std; namespace ident { template<class T> void foo( T*, void* ) { printf( "generic\n" ); } } using namespace ident;
template<class T> void func( T& val ) { foo( &val, (T*)0 ); } struct Base {}; struct Deriv : public Base {}; namespace ident { template<class T> void foo( T* val, Base* ) { printf( "special\n" ); } } int main() { Deriv d; func( d ); } $ g++ -v Using built-in specs. Target: i686-pc-linux-gnu Configured with: /tools/inst/jrichter/tmp.evo1.18630/gcc-4.1.1/configure --prefix=/tools/pkg/gcc/4.1.1 --enable-languages=c,c++ --disable-threads Thread model: single gcc version 4.1.1 $ g++ -o t t.cc $ t generic While GCC 3.4.3 outputs "special" -- Summary: Wrong overload resolution with templates and namespaces Product: gcc Version: 4.1.1 Status: UNCONFIRMED Severity: major Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: joerg dot richter at pdv-fs dot de http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28093