<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 --- - clang fails to properly handle a certain template definition involving pointers to member functions"
   href="https://llvm.org/bugs/show_bug.cgi?id=28683">28683</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang fails to properly handle a certain template definition involving pointers to member functions
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Linux
          </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>C++11
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>beck.ct@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Clang trunk reports an error when compiling the following simple program:

==============

template <typename T, typename... Args>
using member_callback_t = int (T::*)(void *, Args...);

template <typename T, T t> struct dispatch_helper;

template <typename T, typename ... Args, member_callback_t<T, Args...>
target_func>
struct dispatch_helper<member_callback_t<T, Args...>, target_func> {
  static int dispatch(void *) { return 0; }
};

#define DISPATCH(F) &dispatch_helper<decltype(F), (F)>::dispatch

struct test {
  int callback_one(void *, int) { return 0; }
};

typedef int (*desired_sig_t)(void *);

int main() {
  desired_sig_t ptr{DISPATCH(&test::callback_one)};
}

==============

main.cpp:20:21: error: implicit instantiation of undefined template
      'dispatch_helper<int (test::*)(void *, int), &test::callback_one>'
  desired_sig_t ptr{DISPATCH(&test::callback_one)};
                    ^
main.cpp:11:22: note: expanded from macro 'DISPATCH'
#define DISPATCH(F) &dispatch_helper<decltype(F), (F)>::dispatch
                     ^
main.cpp:4:35: note: template is declared here
template <typename T, T t> struct dispatch_helper;
                                  ^
1 error generated.

==============

This code must be compiled with `-std=c++11`.

Both GCC and MSVC 2015 accept this program.

In every released version of clang up to and including 3.9, this code would
cause an internal compiler error, see this earlier bug report from 6 months
ago: <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Clang crashes with internal compiler error when compiling a simple program with templates"
   href="show_bug.cgi?id=26586">https://llvm.org/bugs/show_bug.cgi?id=26586</a>

I'm glad to see that it no longer crashes, but I think the error is not the
correct behavior and clang should accept and compile the program.</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>