From 98b0c888eab94469d3a8f0d55223c7f54c872aa4 Mon Sep 17 00:00:00 2001 From: jwellbelove Date: Thu, 8 Dec 2016 10:47:30 +0000 Subject: [PATCH] Possible fix for 'strict aliasing' warnings. --- src/hash.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/hash.h b/src/hash.h index 3d02ab9b..a89aa9b4 100644 --- a/src/hash.h +++ b/src/hash.h @@ -32,6 +32,7 @@ SOFTWARE. #define __ETL_HASH__ #include +#include // The default hash calculation. #include "fnv_1.h" @@ -322,7 +323,9 @@ namespace etl { if (sizeof(size_t) == sizeof(v)) { - return *reinterpret_cast(&v); + size_t t; + memcpy(&t, &v, sizeof(size_t)); + return t; } else { @@ -344,7 +347,9 @@ namespace etl { if (sizeof(size_t) == sizeof(v)) { - return *reinterpret_cast(&v); + size_t t; + memcpy(&t, &v, sizeof(size_t)); + return t; } else { @@ -366,7 +371,9 @@ namespace etl { if (sizeof(size_t) == sizeof(v)) { - return *reinterpret_cast(&v); + size_t t; + memcpy(&t, &v, sizeof(size_t)); + return t; } else { @@ -387,7 +394,9 @@ namespace etl { if (sizeof(size_t) == sizeof(T*)) { - return reinterpret_cast(v); + size_t t; + memcpy(&t, &v, sizeof(size_t)); + return t; } else {