llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Clang fails to match template argument of type given by another template argument

Open yurivict opened this issue 2 years ago • 3 comments

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

yurivict avatar Oct 14 '22 05:10 yurivict

@llvm/issue-subscribers-clang-frontend

llvmbot avatar Oct 14 '22 05:10 llvmbot

@llvm/issue-subscribers-c-20

llvmbot avatar Oct 14 '22 05:10 llvmbot

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

shafik avatar Oct 14 '22 15:10 shafik