With the following test program, I get compiler errors with g++-3.4 on both i386-linux and x86_64-linux (but not with g++-3.3). namespace A { class B { }; B* transform(B*); template <class T> void transform_in_place(T*& p) { p = A::transform(p); } class C { }; C* transform(C*); }; namespace A { class D { }; D* transform(D*); }; void foo() { A::B *b; A::C *c; A::D *d; A::transform_in_place(b); A::transform_in_place(c); A::transform_in_place(d); } The exact error messages are: ns2.cpp: In function `void A::transform_in_place(T*&) [with T = A::C]': ns2.cpp:25: instantiated from here ns2.cpp:6: error: cannot convert `A::C*' to `A::B*' for argument `1' to `A::B* A::transform(A::B*)' ns2.cpp: In function `void A::transform_in_place(T*&) [with T = A::D]': ns2.cpp:26: instantiated from here ns2.cpp:6: error: cannot convert `A::D*' to `A::B*' for argument `1' to `A::B* A::transform(A::B*)' If I remove the namespace A everywhere, then this file compiles without errors. According to my understanding of the section "Name lookup" under "C++ Misunderstandings" in the info file, this code should be correct since the call to transform depends on a template parameter, so the lookup should happen at instantiation time. (This is a condensed case of problems I'm getting with various versions of gtk--, after correcting other things.) g++ -v shows: Reading specs from /usr/lib/gcc/x86_64-linux/3.4.2/specs Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,treelang --prefix=/usr --libexecdir=/usr/lib --with-gxx-include-dir=/usr/include/c++/3.4 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --program-suffix=-3.4 --enable-__cxa_atexit --enable-libstdcxx-allocator=mt --enable-clocale=gnu --enable-libstdcxx-debug --enable-java-gc=boehm --enable-java-awt=gtk --disable-werror x86_64-linux Thread model: posix gcc version 3.4.2 (Debian 3.4.2-3)
-- Summary: Two-stage lookup doesn't work correctly with namespaces Product: gcc Version: 3.4.2 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: schepler at math dot berkeley dot edu CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18195