From 9ee33b67cabd51eb5f09d6460a0a37341c9a92fb Mon Sep 17 00:00:00 2001 From: "Peter D. Barnes, Jr." Date: Mon, 15 Jul 2013 14:19:57 -0700 Subject: [PATCH] Fix strict aliasing warning. --- src/core/model/hash-function.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/model/hash-function.h b/src/core/model/hash-function.h index df0d9b661..1845d1709 100644 --- a/src/core/model/hash-function.h +++ b/src/core/model/hash-function.h @@ -21,6 +21,7 @@ #ifndef HASHFUNCTION_H #define HASHFUNCTION_H +#include // memcpy #include "simple-ref-count.h" namespace ns3 { @@ -143,8 +144,11 @@ public: } uint32_t GetHash32 (const char * buffer, const size_t size) { - uint64_t hash = GetHash64 (buffer, size); - return *(uint32_t *)(void *)(&hash); + uint32_t hash32; + uint64_t hash64 = GetHash64 (buffer, size); + + memcpy (&hash32, &hash64, sizeof (hash32)); + return hash32; } void clear () { }; private: