From ad3296ffc5576b1dd6aec4007d5ffc748289e21b Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Thu, 23 Mar 2023 11:22:50 +0000 Subject: [PATCH] [SYCL] Fix undefined behaviour in vector printf specifier The use of `%v` vector specifiers requires a length modifier as per OpenCL specification. --- SYCL/DeviceLib/built-ins/printf.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SYCL/DeviceLib/built-ins/printf.cpp b/SYCL/DeviceLib/built-ins/printf.cpp index 36aee3b8f2..27d72070aa 100644 --- a/SYCL/DeviceLib/built-ins/printf.cpp +++ b/SYCL/DeviceLib/built-ins/printf.cpp @@ -64,7 +64,7 @@ int main() { // On SPIRV devices, vectors can be printed via native OpenCL types: using ocl_int4 = sycl::vec::vector_t; { - static const CONSTANT char format[] = "%v4d\n"; + static const CONSTANT char format[] = "%v4hld\n"; ext::oneapi::experimental::printf(format, (ocl_int4)v4); }