<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/146646>146646</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[HIP] User provided deduction guides are considered as __host__ functions
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
MiroPalmu
</td>
</tr>
</table>
<pre>
With clang 20.1.6 following fails to compile ( `clang++ -c -x hip foo.cpp`):
```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:
```cpp
#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 issue: #69366
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzMls2O4jgQx5_GXEpEjvMBHDgA3Wj2sNJc0B6RE1cSrxw7azvQvYd59pUdPrqbUffsnhZFgOxy-V-_KpfDnZOt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