Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: cuda::std::nullopt is undefined in device code #1597

Closed
1 task done
trxcllnt opened this issue Apr 5, 2024 · 0 comments · Fixed by #1598
Closed
1 task done

[BUG]: cuda::std::nullopt is undefined in device code #1597

trxcllnt opened this issue Apr 5, 2024 · 0 comments · Fixed by #1598
Labels
bug Something isn't working right. libcu++ For all items related to libcu++

Comments

@trxcllnt
Copy link
Member

trxcllnt commented Apr 5, 2024

Is this a duplicate?

Type of Bug

Compile-time Error

Component

libcu++

Describe the bug

Attempting to construct a cuda::std::pair that contains a cuda::std::nullopt fails to compile.

#include <cuda/std/optional>

#include <thrust/for_each.h>
#include <thrust/execution_policy.h>

using cuda::std::pair;
using cuda::std::nullopt;
using cuda::std::optional;

__global__ void test(int* x, pair<int, optional<int>>* y) {
  thrust::for_each(thrust::seq, x, x+1, [&](auto const& i) {
    y[i] = {i, nullopt};
  });
}

int main(void) {
  test<<<1, 1, 1>>>(nullptr, nullptr);
}
$ nvcc -c /tmp/test_nullopt.cu -o /tmp/test_nullopt.cu.o
/tmp/test_nullopt.cu(11): error: identifier "cuda::std::__4::nullopt" is undefined in device code

How to Reproduce

  1. See error in godbolt link.
  2. Construct a cuda::std::pair that contains a cuda::std::nullopt in a device lambda

Expected behavior

The code works

Reproduction link

https://godbolt.org/z/K7q3KcaP9

Operating System

No response

nvidia-smi output

No response

NVCC version

No response

@trxcllnt trxcllnt added the bug Something isn't working right. label Apr 5, 2024
@github-project-automation github-project-automation bot moved this to Todo in CCCL Apr 5, 2024
@cccl-authenticator-app cccl-authenticator-app bot moved this from Todo to In Review in CCCL Apr 5, 2024
@miscco miscco added the libcu++ For all items related to libcu++ label Apr 5, 2024
@github-project-automation github-project-automation bot moved this from In Review to Done in CCCL Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working right. libcu++ For all items related to libcu++
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants