cccl
cccl copied to clipboard
[FEA]: Enable exceptions by default
Is this a duplicate?
- [x] I confirmed there appear to be no duplicate issues for this request and that I agree to the Code of Conduct
Area
libcu++
Is your feature request related to a problem? Please describe.
Originally posted by @kroburg at https://github.com/NVIDIA/cuCollections/issues/589
cuda::stream_ref::wait
can throw exceptions
void wait() const
{
_CCCL_TRY_CUDA_API(::cudaStreamSynchronize, "Failed to synchronize stream.", get());
}
_CCCL_NORETURN inline _LIBCUDACXX_INLINE_VISIBILITY void __throw_cuda_error(::cudaError_t, const char*)
{
_CUDA_VSTD_NOVERSION::terminate();
}
but throw
terminates normally with a return value of 0.
_CCCL_NORETURN inline _LIBCUDACXX_INLINE_VISIBILITY void terminate() noexcept
{
__cccl_terminate();
_LIBCUDACXX_UNREACHABLE();
}
_CCCL_NORETURN inline _LIBCUDACXX_INLINE_VISIBILITY void __cccl_terminate() noexcept
{
NV_IF_ELSE_TARGET(NV_IS_HOST, (::std::exit(0);), (__trap();))
_LIBCUDACXX_UNREACHABLE();
}
CCCL disables exceptions by default, meaning that most APIs that are expected to throw exceptions never throw. One reason for this is that destructors should never throw exceptions (#683). Could we revisit this decision and consider enabling exceptions by default?
Describe the solution you'd like
Enable exceptions and find a proper way to "throw".
Describe alternatives you've considered
No response
Additional context
Not sure about the scope of this request, this could be a general CCCL feature request.