-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failure to recognise function type for static member function template in class template #91362
Comments
@llvm/issue-subscribers-clang-frontend Author: Vas Crabb (cuavas)
We noticed this as code using sol2 failing to compile with clang 18. It was reported to that project here: ThePhD/sol2#1581 (also as duplicate ThePhD/sol2#1588).
It’s demonstrated by this reduced test case: #include <type_traits>
template <typename T>
struct class_tmpl {
template <bool B> static int call_e() { return 0; }
template <bool B> static int call_ne() noexcept { return 0; }
template <bool B> static int call() noexcept(std::is_nothrow_copy_assignable<T>::value) { return 0; }
};
int main(int argc, char *argv[])
{
using function_ptr = int (*)();
function_ptr f1 = &class_tmpl<int>::call_e<false>;
function_ptr f2 = &class_tmpl<int>::call_ne<false>;
function_ptr f3 = &class_tmpl<int>::call<false>;
return 0;
} With clang 18 (including clang 18.1), compilation fails with
When the |
When taking a pointer to a static member function template in a class template, clang reports a substitution error if the noexcept specification uses an expression that depends on class template arguments. See llvm/llvm-project#91362 on GitHub.
Even simpler test case (without using the template <typename T>
struct class_tmpl {
template <bool B> static void call_e() { }
template <bool B> static void call_ne() noexcept { }
template <bool B> static void call() noexcept(sizeof(T) > 1) { }
};
int main(int argc, char *argv[])
{
using function_ptr = void (*)();
function_ptr f1 = &class_tmpl<int>::call_e<false>;
function_ptr f2 = &class_tmpl<int>::call_ne<false>;
function_ptr f3 = &class_tmpl<int>::call<false>;
return 0;
} Error with clang 18.1.4:
|
This should have been resolved by #90760. |
It seems godbolt has updated to a build that successfully compiles the code. |
Yeah, so let's close the issue and feel free to re-open it if you find other cases. |
We noticed this as code using sol2 failing to compile with clang 18. It was reported to that project here: ThePhD/sol2#1581 (also as duplicate ThePhD/sol2#1588).
It’s demonstrated by this reduced test case:
With clang 18 (including clang 18.1), compilation fails with
-std=c++14
or-std=c++17
with the following error:When the
noexcept
specification uses an expression that depends on the class template arguments, clang reports a substitution failure. The code compiles with clang 17 and earlier, as far back as clang 6 at least.The text was updated successfully, but these errors were encountered: