Open
Description
With clang 20.1.6 following fails to compile ( clang++ -c -x hip foo.cpp
):
#include<hip/hip_runtime.h>
template <int>
struct Foo {
template <typename... U>
constexpr Foo(U...) {}
};
template <typename... U>
Foo(U...) -> Foo<sizeof...(U)>;
__global__ void f() {
Foo(1, 2, 3);
}
with error message:
foo.cpp:11:5: error: no viable constructor or deduction guide for deduction of template arguments of 'Foo'
11 | Foo(1, 2, 3);
| ^
foo.cpp:8:1: note: candidate function not viable: call to __host__ function from __global__ function
8 | Foo(U...) -> Foo<sizeof...(U)>;
| ^
foo.cpp:4:15: note: candidate template ignored: couldn't infer template argument ''
4 | constexpr Foo(U...) {}
| ^
foo.cpp:4:15: note: implicit deduction guide declared as 'template <int, typename ...U> Foo(U ...) -> Foo<value-parameter-0-0>'
foo.cpp:2:8: note: candidate function template not viable: requires 1 argument, but 3 were provided
2 | struct Foo {
| ^~~
foo.cpp:2:8: note: implicit deduction guide declared as 'template <int> Foo(Foo<value-parameter-0-0>) -> Foo<value-parameter-0-0>'
1 error generated when compiling for gfx906.
However if the deduction guide is removed, then it compiles:
#include <hip/hip_runtime.h>
template <int>
struct Foo {
template <typename... U>
constexpr Foo(U...) {}
};
__global__ void f() {
Foo<3>(1, 2, 3);
}
Potentially relevant: #69366