https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66670
Bug ID: 66670 Summary: "template argument deduction/substitution failed" with function pointers and multiple parameter packs Product: gcc Version: 5.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: michael at ensslin dot cc Target Milestone: --- Take this example: $ cat t28.cpp template<class ... Ts> struct S { template<class ... Us> void foo(void (*)(Us..., Ts ...)) {} }; void f(float, int) {} int main() { S<int>().foo<float>(f); } $ g++-4.9 -std=c++14 t28.cpp t28.cpp: In function ‘int main()’: t28.cpp:10:23: error: no matching function for call to ‘S<int>::foo(void (&)(float, int))’ S<int>().foo<float>(f); ^ t28.cpp:10:23: note: candidate is: t28.cpp:4:7: note: template<class ... Us> void S<Ts>::foo(void (*)(Us ..., Ts ...)) [with Us = {Us ...}; Ts = {int}] void foo(void (*)(Us..., Ts ...)) {} ^ t28.cpp:4:7: note: template argument deduction/substitution failed: t28.cpp:10:23: note: mismatched types ‘int’ and ‘float’ S<int>().foo<float>(f); ^ $ g++-4.9 --version g++-4.9 (Debian 4.9.2-22) 4.9.2 I have reproduced the issue with g++-5.1.0 using https://gcc.godbolt.org/. Note that clang++ has this issue as well, but it works with icc and supposedly even MSVC. The issue can be fixed by swapping the order of Us... and Ts... in the function pointer type, or by replacing the function pointer type by some other type like std::tuple. Related: http://stackoverflow.com/questions/31040075 clang++ error, for completeness: $ clang++-3.7 -std=c++14 t28.cpp t28.cpp:10:11: error: no matching member function for call to 'foo' S<int>().foo<float>(f); ~~~~~~~~~^~~~~~~~~~ t28.cpp:4:7: note: candidate template ignored: failed template argument deduction void foo(void (*)(Us..., Ts ...)) {} ^ 1 error generated. $ clang++-3.7 --version Debian clang version 3.7.0-svn239806-1+b1 (trunk) (based on LLVM 3.7.0) Target: x86_64-pc-linux-gnu Thread model: posix