From caf6cbf2737fd6ac33735293ec197cf29b04a189 Mon Sep 17 00:00:00 2001 From: jwellbelove Date: Thu, 8 Dec 2016 11:22:44 +0000 Subject: [PATCH] Possible fix for 'strict aliasing' warnings. --- src/hash.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/hash.h b/src/hash.h index a89aa9b4..2a3f8ddc 100644 --- a/src/hash.h +++ b/src/hash.h @@ -230,9 +230,9 @@ namespace etl template<> struct hash { - // If it fits into a size_t. size_t operator ()(long v) const { + // If it's the same size as a size_t. if (sizeof(size_t) >= sizeof(v)) { return static_cast(v); @@ -252,9 +252,9 @@ namespace etl template<> struct hash { - // If it fits into a size_t. size_t operator ()(long long v) const { + // If it's the same size as a size_t. if (sizeof(size_t) >= sizeof(v)) { return static_cast(v); @@ -274,9 +274,9 @@ namespace etl template<> struct hash { - // If it fits into a size_t. size_t operator ()(unsigned long v) const { + // If it's the same size as a size_t. if (sizeof(size_t) >= sizeof(v)) { return static_cast(v); @@ -296,9 +296,9 @@ namespace etl template<> struct hash { - // If it fits into a size_t. size_t operator ()(unsigned long long v) const { + // If it's the same size as a size_t. if (sizeof(size_t) >= sizeof(v)) { return static_cast(v); @@ -318,9 +318,9 @@ namespace etl template<> struct hash { - // If it's the same size as a size_t. size_t operator ()(float v) const { + // If it's the same size as a size_t. if (sizeof(size_t) == sizeof(v)) { size_t t; @@ -342,9 +342,9 @@ namespace etl template<> struct hash { - // If it's the same size as a size_t. size_t operator ()(double v) const { + // If it's the same size as a size_t. if (sizeof(size_t) == sizeof(v)) { size_t t; @@ -366,9 +366,9 @@ namespace etl template<> struct hash { - // If it's the same size as a size_t. size_t operator ()(long double v) const { + // If it's the same size as a size_t. if (sizeof(size_t) == sizeof(v)) { size_t t; @@ -392,6 +392,7 @@ namespace etl { size_t operator ()(const T* v) const { + // If it's the same size as a size_t. if (sizeof(size_t) == sizeof(T*)) { size_t t;