Skip to content

Commit 7c6541d

Browse files
[SYCL] Fix stack corruption in sycl::modf for sycl::half type (#10535)
1 parent fc6d573 commit 7c6541d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

sycl/source/detail/builtins_math.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,10 @@ __SYCL_EXPORT s::cl_double sycl_host_modf(s::cl_double x,
784784
}
785785
__SYCL_EXPORT s::cl_half sycl_host_modf(s::cl_half x,
786786
s::cl_half *iptr) __NOEXC {
787-
return std::modf(x, reinterpret_cast<s::cl_float *>(iptr));
787+
float ptr_val_float = *iptr;
788+
auto ret = std::modf(x, &ptr_val_float);
789+
*iptr = ptr_val_float;
790+
return ret;
788791
}
789792
MAKE_1V_2P(sycl_host_modf, s::cl_float, s::cl_float, s::cl_float)
790793
MAKE_1V_2P(sycl_host_modf, s::cl_double, s::cl_double, s::cl_double)

0 commit comments

Comments
 (0)