From 48a787bd0aa5846c171a6503e25d500b2c69496c Mon Sep 17 00:00:00 2001 From: Khairul Azhar Kasmiran Date: Tue, 9 Jan 2024 19:20:07 +0800 Subject: [PATCH] Use `union` in `AArch64_AM_isSVEMaskOfIdenticalElements` type punning fix --- arch/AArch64/AArch64AddressingModes.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/AArch64/AArch64AddressingModes.h b/arch/AArch64/AArch64AddressingModes.h index 69c45b9bd0..5d342a897c 100644 --- a/arch/AArch64/AArch64AddressingModes.h +++ b/arch/AArch64/AArch64AddressingModes.h @@ -827,8 +827,12 @@ static inline uint64_t AArch64_AM_decodeAdvSIMDModImmType12(uint8_t Imm) #define DEFINE_isSVEMaskOfIdenticalElements(T) \ static inline bool CONCAT(AArch64_AM_isSVEMaskOfIdenticalElements, T)(int64_t Imm) \ { \ - T Parts[sizeof(int64_t) / sizeof(T)]; \ - memcpy(Parts, &Imm, sizeof(int64_t) / sizeof(T) * sizeof(T)); \ + union { \ + uint64_t L; \ + T A[sizeof(int64_t) / sizeof(T)]; \ + } U; \ + U.L = Imm; \ + T *Parts = U.A; \ for (int i = 0; i < (sizeof(int64_t) / sizeof(T)); i++) { \ if (Parts[i] != Parts[0]) \ return false; \