From c15601ec4179f0cdb5d1348eaeabe1928b7a0b6d Mon Sep 17 00:00:00 2001 From: Dominique Belhachemi Date: Thu, 1 Oct 2026 04:11:45 +0000 Subject: [PATCH] Fix strict aliasing violation in the neon batch_bool load The sizeof(T) == 4 overload read a `bool const*` through an `unsigned int` lvalue, which is undefined behaviour. Use memcpy instead. --- include/xsimd/arch/xsimd_neon.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/xsimd/arch/xsimd_neon.hpp b/include/xsimd/arch/xsimd_neon.hpp index 6acbe981a..4521f38da 100644 --- a/include/xsimd/arch/xsimd_neon.hpp +++ b/include/xsimd/arch/xsimd_neon.hpp @@ -518,7 +518,9 @@ namespace xsimd template = 0> XSIMD_INLINE batch_bool load_unaligned(bool const* mem, batch_bool, requires_arch) noexcept { - uint8x8_t tmp = vreinterpret_u8_u32(vset_lane_u32(*(unsigned int*)mem, vdup_n_u32(0), 0)); + uint32_t bits; + std::memcpy(&bits, mem, sizeof(bits)); + uint8x8_t tmp = vreinterpret_u8_u32(vset_lane_u32(bits, vdup_n_u32(0), 0)); auto const vmem = batch(vmovl_u16(vget_low_u16(vmovl_u8(tmp)))); auto const zero = batch { 0 }; return { (zero - vmem).data };