Skip to content

Commit d43aef3

Browse files
authored
[SYCL] Fix static_assert with -funsigned-char (#17133)
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.
1 parent db30646 commit d43aef3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

sycl/include/sycl/detail/vector_arith.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ template <typename Self> struct VecOperators {
265265
// ensure we generate 0/1 only (and not 2/-1/etc.).
266266
#if __clang_major__ >= 20
267267
// Not an integral constant expression prior to clang-20.
268-
static_assert((ext_vector<int8_t, 2>{1, 0} == 0)[1] == -1);
268+
static_assert(
269+
static_cast<int8_t>((ext_vector<int8_t, 2>{1, 0} == 0)[1]) == -1);
269270
#endif
270271

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

0 commit comments

Comments
 (0)