-
Notifications
You must be signed in to change notification settings - Fork 787
[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
Conversation
ping, we are working on non-x86 target support, this is a blocker for AArch64 where |
ping again, it's been two weeks now, could someone review this please? |
ping again @intel/llvm-reviewers-runtime |
Sorry about the delay. Could you also rebase your PR over the latest SYCL branch? The CI results are quite old, rebasing would re-trigger the CI. |
The type of (ext_vector<int8_t, 2>{1, 0} == 0)[1] has type char, not int8_t, and therefore depending on whether -funsigned-char is in effect may either have the value -1 or have the value 255. Cast to int8_t to ensure it always gets taken as signed. This is only needed for the static_assert: the rest of the code already works for signed and unsigned plain char alike.
Sure, changed to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
@intel/llvm-gatekeepers This is ready to be merged, thanks (Edit: ha, already merged just as I was posting this. thanks!) |
static_assert( | ||
static_cast<int8_t>((ext_vector<int8_t, 2>{1, 0} == 0)[1]) == -1); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
.
The type of (ext_vector<int8_t, 2>{1, 0} == 0)[1] has type char, not int8_t, and therefore depending on whether -funsigned-char is in effect may either have the value -1 or have the value 255. Cast to int8_t to ensure it always gets taken as signed. This is only needed for the static_assert: the rest of the code already works for signed and unsigned plain char alike.