It looks like the comparison operators generated by operator<=>
definition (defaulted or otherwise) can’t be used in device functions:
struct S
{
int x;
auto operator<=>(const S& other) const = default;
};
__host__ __device__ void foo()
{
S{1} < S{2};
}
This results in (Godbolt)
<source>(10): warning #20013-D: calling a constexpr __host__ function("__unspec") from a __host__ __device__ function("foo") is not allowed. The experimental flag '--expt-relaxed-constexpr' can be used to allow this.
S{1} < S{2};
^
Remark: The warnings can be suppressed with "-diag-suppress <warning-number>"
<source>(10): warning #20013-D: calling a constexpr __host__ function("operator<") from a __host__ __device__ function("foo") is not allowed. The experimental flag '--expt-relaxed-constexpr' can be used to allow this.
S{1} < S{2};
^
Compiler returned: 0
Adding __host__ __device__
just adds more warnings, and explicitly defining the operator also doesn’t work.