From 32e6276baffaa558314e91db0c4b4603caaae042 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sun, 24 Jul 2016 00:34:55 -0400 Subject: [PATCH] Prefer union access over pointer cast Also see http://stackoverflow.com/a/38547909/608639 --- blake2.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/blake2.cpp b/blake2.cpp index cb274c99..e8f3ca68 100644 --- a/blake2.cpp +++ b/blake2.cpp @@ -14,7 +14,7 @@ NAMESPACE_BEGIN(CryptoPP) // Uncomment for benchmarking C++ against SSE2 or NEON -// #undef CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE +#undef CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE // #undef CRYPTOPP_BOOL_NEON_INTRINSICS_AVAILABLE // Visual Studio needs both VS2005 (1400) and _M_64 for SSE2 and _mm_set_epi64x() @@ -40,14 +40,14 @@ NAMESPACE_BEGIN(CryptoPP) #if defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x5130) inline __m128i _mm_set_epi64x(const uint64_t a, const uint64_t b) { - union INT_128_64 { + union INT_128_64x2 { __m128i v128; uint64_t v64[2]; }; - INT_128_64 v; - v.v64[0] = b; v.v64[1] = a; - return *(reinterpret_cast<__m128i*>(v.v64)); + INT_128_64x2 val; + val.v64[0] = b; val.v64[1] = a; + return val.v128; } #endif