[LLVMbugs] [Bug 23949] New: "failed template argument deduction" with function pointers and multiple parameter packs

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jun 25 07:56:15 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=23949

            Bug ID: 23949
           Summary: "failed template argument deduction" with function
                    pointers and multiple parameter packs
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: michael at ensslin.cc
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

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);
}

$ 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

Note that g++ has this issue as well, but it supposedly works with 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

g++ error, for completeness:

$ 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

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150625/f6bb6a15/attachment.html>


More information about the llvm-bugs mailing list