Skip to content

Commit b59b8f0

Browse files
committed
Avoid dereferencing type-punned pointer.
This fixed #382.
1 parent 569172d commit b59b8f0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

include/xsimd/types/xsimd_base.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#define XSIMD_BASE_HPP
1313

1414
#include <cstddef>
15+
#include <cstring>
1516
#include <complex>
1617
#include <iterator>
1718
#include <ostream>
@@ -603,7 +604,8 @@ namespace xsimd
603604
{ \
604605
TYPE z0(0), z1(0); \
605606
using int_type = as_unsigned_integer_t<TYPE>; \
606-
*reinterpret_cast<int_type*>(&z1) = ~int_type(0); \
607+
int_type value(~int_type(0)); \
608+
std::memcpy(&z1, &value, sizeof(int_type)); \
607609
return select(src, batch<TYPE, N>(z1), batch<TYPE ,N>(z0)); \
608610
}
609611

0 commit comments

Comments
 (0)