C++20 concept support in CUDA 12

The programming guide states that … all C++20 language features are supported in nvcc version 12.0 and later, subject to restrictions described here… I checked the restrictions and the C++20 concept was not mentioned, implying a full support. With that, the following code has compile error on nvcc 12.1:

// nvcc bug.cu -std=c++20
#include <type_traits>

template <typename T>
concept ReturnVoid = requires(T &t) { []<typename... Args>(void(Args...)) {}(t); };

template <auto c>
    requires(ReturnVoid<std::remove_pointer_t<decltype(c)>>)
void g()
{
}

void foo(double, int){};

int main()
{
    g<foo>();
    return 0;
}
error: no instance of function template "g" matches the argument list
      g<foo>();

There is no error, however, on gcc 11.3.0.

Is this a bug in nvcc, or did I miss anything?

The usual suggestion would be to test on the latest public version of CUDA, if it still manifests, file a bug.

(I can reproduce your observation on godbolt, although it only goes to CUDA 12.1, at the moment.)

1 Like

Thanks. I upgraded to the latest CUDA (12.2 runtime) and the problem persists. I’ve filed a bug report as suggested.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.