- Even though only void is still accepted as the deduced return type, enabling deduction/instantiation on the return type allows more consistent coding.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Comment Actions
Nice. I'd mention in the commit message that NVCC does not support deduced return type for kernel functions.
Comment Actions
Just tried with NVCC from CUDA 10, except auto-based deduced type is not supported, type deduction in a template is supported, the following test code passes compilation with NVCC
#include <cuda.h> template <typename T> __global__ T foo() { } void f0() { foo<void><<<0, 0>>>(); #if 0 foo<int><<<0, 0>>>(); #endif } template <bool Cond, typename T = void> struct enable_if { typedef T type; }; template <typename T> struct enable_if<false, T> {}; template <int N> __global__ auto bar() -> typename enable_if<N == 1>::type { } template <int N> __global__ auto bar() -> typename enable_if<N == 2>::type { } void f3() { bar<1><<<0, 0>>>(); bar<2><<<0, 0>>>(); #if 0 bar<3><<<0, 0>>>(); #endif }
s/#if 0/#if 1 also shows NVCC could give the error on the correct position but the message, IMHO, is misleading compared to the one from clang.