GCC fails to compile the following code: struct A { void foo(const int &); void foo(float); }; template <typename... Args> void bar(void (A::*memfun)(Args...), Args... args); void go(const int& i) { bar<const int &>(&A::foo, i); } The error message is shown below: t.C:10:30: error: no matching function for call to ‘bar(<unresolved overloaded function type>, const int&)’ bar<const int &>(&A::foo, i); ^ t.C:7:6: note: candidate: template<class ... Args> void bar(void (A::*)(Args ...), Args ...) void bar(void (A::*memfun)(Args...), Args... args); ^ t.C:7:6: note: template argument deduction/substitution failed: t.C:10:30: note: inconsistent parameter pack deduction with ‘const int&’ and ‘int’ bar<const int &>(&A::foo, i); As the type is explicitly specified, why GCC would like to "deduce" it?
(In reply to Cong Hou from comment #0) > As the type is explicitly specified, why GCC would like to "deduce" it? Probably because with a variadic template there could be additional arguments that haven't been explicitly specified and so need to be deduced. However, in this case the number of function arguments should tell the compiler the pack only contains one type, and therefore nothing more needs to be deduced.
Author: jason Date: Wed Jun 18 22:13:40 2014 New Revision: 211808 URL: https://gcc.gnu.org/viewcvs?rev=211808&root=gcc&view=rev Log: PR c++/61507 * pt.c (resolve_overloaded_unification): Preserve ARGUMENT_PACK_EXPLICIT_ARGS. Added: trunk/gcc/testsuite/g++.dg/cpp0x/variadic159.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/pt.c
Author: jason Date: Thu Jun 19 09:34:48 2014 New Revision: 211819 URL: https://gcc.gnu.org/viewcvs?rev=211819&root=gcc&view=rev Log: PR c++/61507 * pt.c (resolve_overloaded_unification): Preserve ARGUMENT_PACK_EXPLICIT_ARGS. Added: branches/gcc-4_9-branch/gcc/testsuite/g++.dg/cpp0x/variadic159.C Modified: branches/gcc-4_9-branch/gcc/cp/ChangeLog branches/gcc-4_9-branch/gcc/cp/pt.c
Thus I would say fixed for 4.9.1.