I am trying to static cast a function pointer to a specific function overload, but it seems that clang still parses the noexcept statement of the (unused) template specialization and thus generates a compiler error. GCC doesn't seem to care about the noexcept if the corresponding function overload is unused.
template<typename T>
void fun( T ) noexcept( T(1) ){}
void fun(int) {}
void fun(int*) {}
int main () {
int a;
fun(&a); //calling works fine
fun(a);
static_cast<void(*)(int*)>(&fun); // static casting doesn't
}
Which compiler is wrong here?
Does the standard specify what exactly should be compiled when casting function pointers to specific overloads?
EDIT: After Maxim's comment, i put back the second noexcept into the example and it compiled on both gcc and clang.
So here is another example, where it actually fails with noexcept(noexcept(...))