http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47765
Jason Merrill <jason at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |ASSIGNED Last reconfirmed| |2011-09-08 Ever Confirmed|0 |1 --- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> 2011-09-08 16:15:24 UTC --- 14.8.2/6: At certain points in the template argument deduction process it is necessary to take a function type that makes use of template parameters and replace those template parameters with the corresponding template arguments. This is done at the beginning of template argument deduction when any explicitly specified template arguments are substituted into the function type, and again at the end of template argument deduction when any template arguments that were deduced or obtained from default arguments are substituted. So, when we start to try to evaluate b.foo<char>, we substitute 'char' for T in both templates, so they become template<typename T2> void foo(const A<char>& r) {} void foo(const B<char>& r) {} 14.8.1/6: Implicit conversions (Clause 4) will be performed on a function argument to convert it to the type of the corresponding function parameter if the parameter type contains no template-parameters that participate in template argument deduction. [ Note: Template parameters do not participate in template argument deduction if they are explicitly specified. So we no longer do deduction on the first parameter, but rather check for a conversion. What is unclear in the standard is when exactly the conversion should happen. Currently G++ and EDG seem to check for a conversion during argument deduction, which leads to instantiation of A<char> and thus the error you see. But another reasonable interpretation would be to skip the parameter during deduction and then let normal overload resolution check for the conversion; in that case deduction would fail for the first foo and so we never check the conversion, so we don't try to instantiate A<char>. clang accepts this testcase, so it seems likely that this is what they are doing.