Skip to content

Commit 4076592

Browse files
committed
Fix Linux strict alias mode compilation error.
1 parent bf40594 commit 4076592

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

sycl/include/sycl/ext/oneapi/experimental/bfloat16.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#if !defined(__SYCL_DEVICE_ONLY__)
1515
#include <cmath>
16+
#include <cstring> // for std::memcpy
1617
#endif
1718

1819
namespace sycl {
@@ -65,7 +66,9 @@ class bfloat16 {
6566
#else
6667
uint32_t bits = a;
6768
bits <<= 16;
68-
return *(reinterpret_cast<float *>(&bits));
69+
float res;
70+
std::memcpy(&res, &bits, sizeof(res));
71+
return res;
6972
#endif
7073
}
7174

0 commit comments

Comments
 (0)