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

            Bug ID: 42651
           Summary: noreturn attributes prevent template function pointer
                    arguments from working
           Product: clang
           Version: 8.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangb...@nondot.org
          Reporter: j...@alien8.de
                CC: blitzrak...@gmail.com, dgre...@apple.com,
                    erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
                    richard-l...@metafoo.co.uk

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to