http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23885
rockeet <rockeet at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |rockeet at gmail dot com --- Comment #9 from rockeet <rockeet at gmail dot com> 2011-12-13 09:35:29 UTC --- ///// Code Begin #include <stdio.h> class A {}; void f(A) { printf("%s\n", __PRETTY_FUNCTION__); } class B {}; template<class T> void f(T) { printf("%s\n", __PRETTY_FUNCTION__); } // now g(T) knew A,B,int,... // phase 1 lookup just success for f(A) template<class T> void g(T x) { f(x); } // after definition of g(T) and class B void f(B) { printf("%s\n", __PRETTY_FUNCTION__); } void f(int x) { printf("%s\n", __PRETTY_FUNCTION__); } void f(int*x) { printf("%s\n", __PRETTY_FUNCTION__); } int main(int argc, char** argv) { g(A()); // should always(phase 1 and phase 2) be OK g(B()); // f(B) definition is after g(T) definition, phase 1 just got f(A) and f(T) g(B()); // but phase 2 got f(B) g(100); // intend to let g calling f(int), but got f(T) in g++ 4.1.2 and 4.6.0, 4.7.0, others not tested g(&argc); // intention: similar as g(100) return 0; } ///// Code End The output of above code shown that "associated sets of namespaces and classes of fundamental types are both empty" is really true! But pre g++ 3.4.6 and clang treat fundamental types as same as user defined types. //// Begin Compile With g++ 4.6.0 $g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/opt/libexec/gcc/x86_64-unknown-linux-gnu/4.6.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../gcc-4.6.0-src/configure --prefix=/opt --with-gmp=/opt --with-mpfr=/opt --with-mpc=/opt --with-ppl=/opt --with-cloog=/opt --with-local-prefix=/opt --enable-languages=c,c++ Thread model: posix gcc version 4.6.0 (GCC) $ g++ twophaselookup2.cpp $ ./a.out //// End Compile With g++ 4.6.0 //// Begin Compile With g++ 3.4.6 void f(A) void f(B) void f(B) void f(int) void f(int*) //// Begin Compile With g++ 3.4.6 apple clang produced the same result as g++ 3.4.6