[BUG]: value_or_const.pass.cpp: : instantiation of optional with a non-object type is undefined behavior
- Dominant language
- C++
- Stars
- 2.5k
- Forks
- 486
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 295
Description
### Is this a duplicate?
- [x] I confirmed there appear to be no [duplicate issues](https://github.com/NVIDIA/cccl/issues) for this bug and that I agree to the [Code of Conduct](CODE_OF_CONDUCT.md)
### Type of Bug
Compile-time Error
### Component
libcu++
### Describe the bug
optional.object.observe/value_or_const.pass.cpp errors out because it attempts to instantiate `optional`: https://godbolt.org/z/T8Ed5aM5s
https://github.com/NVIDIA/cccl/blob/813e75eb761abf1be641d89c2d8f0a1ecb9a48e2/libcudacxx/test/libcudacxx/std/utilities/optional/optional.object/optional.object.observe/value_or_const.pass.cpp#L74
```
/opt/compiler-explorer/libs/cccl/trunk/libcudacxx/include/cuda/std/__optional/optional_base.h(134): error: static assertion failed with "instantiation of optional with a non-object type is undefined behavior"
static_assert(is_object_v, "instantiation of optional with a non-object type is undefined behavior");
^
detected during:
instantiation of class "cuda::std::__4::__optional_destruct_base<_Tp, true> [with _Tp=X &]" at line 188
instantiation of class "cuda::std::__4::__optional_storage_base<_Tp> [with _Tp=X &]" at line 267
instantiation of class "cuda::std::__4::__optional_copy_base<_Tp, > [with _Tp=X &, =cuda::std::__4::__smf_availability::__trivial]" at line 310
instantiation of class "cuda::std::__4::__optional_move_base<_Tp, > [with _Tp=X &, =cuda::std::__4::__smf_availability::__trivial]" at line 351
instantiation of class "cuda::std::__4::__optional_copy_assign_base<_Tp, > [with _Tp=X &, =cuda::std::__4::__smf_availability::__trivial]" at line 393
instantiation of class "cuda::std::__4::__optional_move_assign_base<_Tp, > [with _Tp=X &, =cuda::std::__4::__smf_availability::__trivial]" at line 102 of /opt/compiler-explorer/libs/cccl/trunk/libcudacxx/include/cuda/std/__optional/optional.h
instantiation of class "cuda::std::__4::optional<_Tp> [with _Tp=X &]" at line 54 of
```
### How to Reproduce
See https://godbolt.org/z/T8Ed5aM5s
It appears to be an issue with the test, not with the library itself.
### Expected behavior
Test should compile.
### Reproduction link
https://godbolt.org/z/T8Ed5aM5s
### Operating System
_No response_
### nvidia-smi output
_No response_
### NVCC version
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.