In the book "C++ Templates - The Complete Guide" section 8.3, the following code snippet is given: template<typename F, typename T> void apply(F f, T t) { f(t); } template<typename T> void multi(T) { } template<typename T> void multi(T*) { } int main() { apply(&multi<int>, 7); return 0; } My understanding is that &multi<int> here instantiates two functions of types void (*)(int) and void (*)(int*) with no ways to disambiguate and therefore F cannot be deducted. However, gcc currently deducts F as void (*)(int) and ultimately calls multi(int). This is the same case for gcc 4.4.3, gcc 4.6.2, gcc 4.7.0 20111112 snapshot and probably other versions.
Confirmed.
Author: jason Date: Wed Jan 11 16:46:57 2012 New Revision: 183099 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183099 Log: PR c++/51613 * pt.c (resolve_overloaded_unification): Compare types with same_type_p, not decls_match. Added: trunk/gcc/testsuite/g++.dg/template/explicit-args5.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/pt.c trunk/gcc/testsuite/ChangeLog
Fixed for 4.7. Not backporting fixes for invalid code bugs.