The following program fails to compile with GCC 4.3.3 (but compiles successfully with Comeau C/C++ 4.3.10.1 and MSVC 15.00.30729.01):
template <typename T1, typename T2> class B {}; template <typename T> class D : public B<T, T> {}; template <typename T1, typename T2> void f(B<T1, T2>*) {} template <template <typename, typename> class U, typename T1, typename T2> void g(U<T1, T2>*) {} template <typename T1, typename T2, template <typename, typename> class U> void h(U<T1, T2>*) {} int main() { B<long, long> bll; D<long> dl; f(&bll); g(&bll); h(&bll); f(&dl); g(&dl); // error: no matching function for call to g(D<long int>*) h(&dl); // error: no matching function for call to h(D<long int>*) return 0; } According to ISO/IEC 14882-2003 14.8.2.1.3 [temp.deduct.call]: "If P is a class, and P has the form template-id, then A can be a derived class of the deduced A." And from 14.8.2.4.9 [temp.deduct.type]: "A template type argument T, a template template argument TT or a template non-type argument i can be deduced if P and A have one of the following forms: [...] TT<T> [...]" Therefore, it seems like this code should be valid. As a partial workaround, changing the first failing line to "g<B>(&dl);" eliminates that error without excessive readability burden. A similar workaround for the second failing line, "h<long, long, B>(&dl);", is rather burdensome in real-world code (e.g. where arguments T1 and T2 are deeply composed template types). $ g++ -v Using built-in specs. Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.3.3-5ubuntu4' --with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4) -- Summary: Deduction of template template argument via base class fails Product: gcc Version: 4.3.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: trevor at scurrilous dot com GCC build triplet: x86_64-linux-gnu GCC host triplet: x86_64-linux-gnu GCC target triplet: x86_64-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42329