<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Give better error message for template argument deduction failure when taking the address of a function template"
   href="https://llvm.org/bugs/show_bug.cgi?id=25660">25660</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Give better error message for template argument deduction failure when taking the address of a function template
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>ehsan@mozilla.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>