Consider the following code:
constexpr __host__ void foo() { }
__global__ void baz()
{
if constexpr(1==2) { foo(); }
}
this fails to compile with CUDA 11.3.1's NVCC. However, if I remove the constexpr
from foo()
- it does compile.
How come? Is this a bug?
This was an NVCC bug, as of CUDA 11.3.1, filed as:
https://developer.nvidia.com/nvidia_bug/3328502
(it's difficult to access their bug tracking system, try going through https://developer.nvidia.com first to login, then look at your bugs, then replace the bug number.)
It was fixed at some point before CUDA 12.0.