[llvm-bugs] [Bug 25660] New: Give better error message for template argument deduction failure when taking the address of a function template

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Nov 27 11:56:22 PST 2015


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

            Bug ID: 25660
           Summary: Give better error message for template argument
                    deduction failure when taking the address of a
                    function template
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ehsan at mozilla.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Code:

#include <utility>

using FuncType1 = void(*)();
using FuncType2 = void(*)(int);
using FuncType3 = void(*)(char, float);

struct Symbols {
   FuncType1 f1;
   FuncType2 f2;
   FuncType3 f3;
};

Symbols* GetOriginalSymbols();
Symbols* GetSymbols();

template <typename... Args>
void DebugWrapperf1(Args&&... args) {
  GetOriginalSymbols()->f1(args...);
}

template <typename... Args>
void DebugWrapperf2(Args&&... args) {
  GetOriginalSymbols()->f2(args...);
}

void Initialize() {
    GetSymbols()->f1 = &DebugWrapperf1;
    GetSymbols()->f2 = &DebugWrapperf2;
}

Clang's error:


$ clang++ -c test.cpp -std=c++11
test.cpp:28:22: error: assigning to 'FuncType2' (aka 'void (*)(int)') from
incompatible type '<overloaded function type>'
    GetSymbols()->f2 = &DebugWrapperf2;
                     ^ ~~~~~~~~~~~~~~~
test.cpp:22:6: note: candidate function
void DebugWrapperf2(Args&&... args) {
     ^
1 error generated.


It would be helpful if clang told us that the issue here is that Arg&& cannot
be matched against int.  It would be really helpful if clang also gave a fix-it
hint to get rid of the && in DebugWrapperf2's variadic template argument.

-- 
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/20151127/f88ab341/attachment.html>


More information about the llvm-bugs mailing list