<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - noreturn attributes prevent template function pointer arguments from working"
   href="https://bugs.llvm.org/show_bug.cgi?id=42651">42651</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>noreturn attributes prevent template function pointer arguments from working
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>8.0
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>js@alien8.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I'm working on a piece of code that has template functions specialized on
function pointers. These pointers usually point to functions declared noreturn.
This generally works with gcc, but fails with clang due to errors like:

% clang++ -std=c++11 -c syscall.cpp
syscall.cpp:8:7: error: address of overloaded function 'send_msg' cannot be
static_cast to type 'void (*)()'
  d ? static_cast<void (*)()>(send_msg<b>) : nullptr;
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
syscall.cpp:6:27: note: candidate function template
template <void()> void a::send_msg() {
                          ^
syscall.cpp:10:18: error: explicit instantiation of 'send_msg' does not refer
to a function template, variable
      template, member function, member class, or static data member
template void a::send_msg<a::c>();
                 ^
syscall.cpp:6:27: note: candidate template ignored: invalid
explicitly-specified argument for 1st template parameter
template <void()> void a::send_msg() {
                          ^
2 errors generated.

creduce reduced the problem to this:

```
class a {
  __attribute__((noreturn)) static void b();
  __attribute__((noreturn)) static void c();
  template <void()> static void send_msg();
};
template <void()> void a::send_msg() {
  int d;
  d ? static_cast<void (*)()>(send_msg<b>) : nullptr;
}
template void a::send_msg<a::c>();
```

Removing the noreturn attributes works around the problem.</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>