http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60177
Bug ID: 60177 Summary: Unable to deduce template base of derived class in function template accepting a simple-template-id Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: filip.roseen at gmail dot com template<class> struct Base { }; struct Derived : Base<void> { }; template<template<typename> class TT, typename T> void func (TT<T>) { } int main () { func (Derived { }); } - - - - - - - - - - - - - - - - - - - - - - - - - - main.cpp: In function 'int main()': main.cpp:9:20: error: no matching function for call to 'func(Derived)' func (Derived { }); ^ main.cpp:9:20: note: candidate is: main.cpp:6:6: note: template<template<class> class TT, class T> void func(TT<T>) void func (TT<T>) { } ^ main.cpp:6:6: note: template argument deduction/substitution failed: main.cpp:9:20: note: can't deduce a template for 'TT<T>' from non-template type 'Derived' func (Derived { }); - - - - - - - - - - - - - - - - - - - - - - - - - - gcc rejects the snippet which is a violation of [temp.deduct.call]/4 (`clang` and `msvc` accepts the code). `TT<T>` is a `simple-template-id` and the standard says that if a derived type is passed to such context it should be deduced to a suitable base of that passed type. Correct behavior is that the deduced template parameters for `func (Derived {})` should be `TT = Base, T = void`.