Skip to content

[SYCL][SYCL2020] Add missing noexcept to ctors of public SYCL RT classes - #23184

Open
dm-vodopyanov wants to merge 1 commit into
intel:syclfrom
dm-vodopyanov:add-inline-to-some-ctors
Open

dm-vodopyanov wants to merge 1 commit into
intel:syclfrom
dm-vodopyanov:add-inline-to-some-ctors

Conversation

@dm-vodopyanov

@dm-vodopyanov dm-vodopyanov commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

This patch adds missing noexcept to some of the classes in accordance with SYCL 2020 spec update above.

Note: this patch must be merged only AFTER this one:

…asses

Note: this patch must be merged AFTER this one:

- KhronosGroup/SYCL-Docs#1044

This patch add missing `noexcept` to some of the classes in accordance
with SYCL 2020 spec update above.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The test cannot detect a missing move constructor when a non-throwing copy constructor accepts rvalues.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Implements a pending SYCL 2020 update requiring non-throwing move operations for public runtime classes.

Changes:

  • Marks device and buffer move constructors noexcept.
  • Adds explicit move operations to h_item.
  • Adds compile-time checks for common-semantics classes.
File summaries
File Description
sycl/include/sycl/buffer.hpp Makes buffer moves non-throwing.
sycl/include/sycl/device.hpp Updates the public device declaration.
sycl/source/device.cpp Updates the device implementation.
sycl/include/sycl/h_item.hpp Adds move constructor and assignment.
sycl/test/basic_tests/common_semantics_noexcept.cpp Tests move-operation requirements.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +19 to +20
static_assert(std::is_nothrow_move_constructible_v<__VA_ARGS__>, \
#__VA_ARGS__ " must be nothrow move constructible"); \

@Robertkq Robertkq left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, LGTM

I did not check if other classes not modified by this PR need noexcept, although testing side of this PR seems to test everything.

My understanding is that all classes should define (even if = default), move constructor & move assignment operator with explicit noexcept, even if most compilers would implicitly add noexcept.

Also a little bit related, I've tried to extend the explicit noexcept to the destructor, but the decision was to leave out the explicit noexcept in the case of the destructor, perhaps this PR (or some other, no issue) could add the default destructor for classes that do not explicitly define one? (reiterating, no explicit noexcept needed for =default destructor)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
h_item(h_item &&hi) noexcept = default;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
h_item &operator=(h_item &&hi) noexcept = default;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants