cccl icon indicating copy to clipboard operation
cccl copied to clipboard

[BUG]: cuda::std::variant, incoherent behaviour with Ambigous affectation

Open PaulGannay opened this issue 9 months ago • 1 comments

Is this a duplicate?

  • [x] I confirmed there appear to be no duplicate issues for this bug and that I agree to the Code of Conduct

Type of Bug

Compile-time Error

Component

libcu++

Describe the bug

Affecting an ambiguous value to a cuda::std::variant (for instance, trying to affect an int to a cuda::std::variant<long, short>) has a different comportment depending on the compiler pass.

How to Reproduce

  1. See godbold link bellow
  2. Observe that it fails to compile
  3. change the #if 0 to #if 1
  4. It still fails to compile despite the condition being the negation of the first one

Expected behavior

Both passes of the compiler should have the same behaviour (either allow or disallow such affectation). To get the same behaviour as std::variant, I believe that the assignment should be allowed (see here: https://godbolt.org/z/76fTqh5Yn).

Reproduction link

https://godbolt.org/z/fG5bvbcWz

Operating System

No response

nvidia-smi output

No response

NVCC version

tested with nvcc12.6.2 and nvcc12.8.1

PaulGannay avatar Apr 10 '25 07:04 PaulGannay

Thanks for opening this issue, I believe this is a problem with the way system headers are treated with nvcc, I have changed the implementation slightly to ensure that we are using a workaround that we designed recently

miscco avatar Apr 10 '25 08:04 miscco

@PaulGannay sorry, this is taking a bit longer than expected, we are running into compiler bugs that are nontrivial to work around

miscco avatar Apr 30 '25 16:04 miscco

No problem, thank you for taking the time to look at it.

PaulGannay avatar May 05 '25 07:05 PaulGannay

This should be fixed now on main, sorry for the long wait there were some compiler issues in the way

miscco avatar May 07 '25 11:05 miscco