Skip to content

Commit 45aa49b

Browse files
authored
[SYCL] Fix incorrect sycl::vec<bool, N> constructor behavior (#9035)
Update a `sycl::vec` constructor to ensure that element values are first converted to `DataT` before being stored as `vec_data_t<DataT>`. Add a test case that uses the updated constructor. Fixes bug from #8942. Signed-off-by: Michael Aziz <[email protected]>
1 parent 370346d commit 45aa49b

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

sycl/include/sycl/types.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ template <typename Type, int NumElements> class vec {
739739
template <size_t... Is>
740740
constexpr vec(const std::array<vec_data_t<DataT>, NumElements> &Arr,
741741
std::index_sequence<Is...>)
742-
: m_Data{Arr[Is]...} {}
742+
: m_Data{vec_data_t<DataT>(static_cast<DataT>(Arr[Is]))...} {}
743743
744744
public:
745745
using element_type = DataT;

sycl/test/basic_tests/vectors/vectors.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ int main() {
129129
check_convert_from<sycl::half>();
130130
check_convert_from<float>();
131131
check_convert_from<double>();
132+
check_convert_from<bool>();
132133

133134
return 0;
134135
}

0 commit comments

Comments
 (0)