The code example below compiles successfully under Microsoft Visual Studio 2005 SP1. Minimal steps to reproduce: ------------------------------------------------- template<typename T> void foo(T &) {} int main() { struct A { int m; }; A a; foo(a); return 0; } ----------------------------------------- alexz@alexz-debian:~$ g++ test.cpp test.cpp: In function 'int main()': test.cpp:11: error: no matching function for call to 'foo(main()::A&)' alexz@alexz-debian:~$ g++ -v Using built-in specs. Target: i486-linux-gnu Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr --with-tune=i686 --enable-checking=release i486-linux-gnu Thread model: posix gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
This is illegal in C++03, per 14.3.1/2, and no strictly conforming compiler accepts it.