Issue 146646
Summary [HIP] User provided deduction guides are considered as __host__ functions
Labels new issue
Assignees
Reporter MiroPalmu
    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


_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to