Skip to content

[SYCL] Fix static_assert with -funsigned-char #17133

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

Merged
merged 1 commit into from
Mar 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion sycl/include/sycl/detail/vector_arith.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ template <typename Self> struct VecOperators {
// ensure we generate 0/1 only (and not 2/-1/etc.).
#if __clang_major__ >= 20
// Not an integral constant expression prior to clang-20.
static_assert((ext_vector<int8_t, 2>{1, 0} == 0)[1] == -1);
static_assert(
static_cast<int8_t>((ext_vector<int8_t, 2>{1, 0} == 0)[1]) == -1);
Comment on lines +268 to +269
Copy link
Contributor

Choose a reason for hiding this comment

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

I think a better fix would be to use the same expression here and in line 272 (whatever it would be). @hvdijk any thoughts on that?

Copy link
Contributor Author

@hvdijk hvdijk Mar 17, 2025

Choose a reason for hiding this comment

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

Ideally yes, but the below needs to construct a vector which cannot be done with static_cast (and also, ext_vector is not available on GCC, but that might not matter here), and the below reinterpret_cast makes the expression non-constant so it cannot be used in static_assert.

#endif

tmp = reinterpret_cast<decltype(tmp)>((tmp != 0) * -1);
Expand Down