llvm-project
llvm-project copied to clipboard
Clang fails to match template argument of type given by another template argument
Clang fails on this code with -std=c++20
:
template<typename T, T maxT>
T nnn() {
return 0;
}
void x() {
nnn<float, 1.f>();
}
error:
testcase.cpp:8:2: error: no matching function for call to 'nnn'
nnn<float, 1.f>();
^~~~~~~~~~~~~~~
testcase.cpp:3:3: note: candidate template ignored: invalid explicitly-specified argument for template parameter 'maxT'
T nnn() {
^
1 error generated.
clang versions 14, 15, 16 fail. gcc-11 succeeds.
FreeBSD 13.1
@llvm/issue-subscribers-clang-frontend
@llvm/issue-subscribers-c-20
This is p1907r1 was came in with C++20 and if we check out the clang status page it is marked as partial.
godbolt showing gcc/MSVC accept this in C++20/latest mode: https://godbolt.org/z/jvvqYsP3G