KhronosGroup / KhronosGroup/SYCL-Docs

What does "Exception-handling cannot be used inside a device function" actually mean?

Open
#543 22 comments 0 reactions 1 assignee Claimed by @tahonermann View on GitHub
clarification
Dominant language
JavaScript
Stars
158
Forks
80
Avg merge
7d 6h
Merged PRs (30d)
5

Description

[Section 5.4 (Language restrictions for device functions) of revision 8 of the SYCL 2020 specification](https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#sec:language.restrictions.kernels) states:
> Exception-handling cannot be used inside a device function. `noexcept` is allowed.

What does "Exception-handling cannot be used" mean? (and why is that hyphen there?)

- Does it mean that use of exception handling language features makes the program ill-formed?
- For all exception handling language features? Or just `throw` expressions? Should `try` and `catch` be allowed given that they are allowed in `constexpr` evaluation in C++20 courtesy of adoption of [P1002R1 (Try-catch blocks in constexpr functions)](https://wg21.link/p1002r1)?
- For standard library functions like `std::current_exception()`?
- Or perhaps it means that exception handling language features don't make the program ill-formed, but that evaluating a `throw` expression perhaps results in some unspecified or undefined behavior?

Would an implementation that allows use of exception handling language features in device code such that evaluation of a `throw` expression results in an immediate call to `std::terminate()` or `std::abort()` be a conforming implementation? Such a translation mode would allow more C++ code, including C++ standard library features, to be usable in device code.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.