From 37e586820080437a7e26441b2dd54398cc1d4d48 Mon Sep 17 00:00:00 2001 From: jan p springer Date: Mon, 14 Apr 2014 00:13:20 +0100 Subject: [PATCH] fixed: warning wrt. strict aliasing on gcc 4.8.2/clang3.3 --- glm/core/func_exponential.inl | 6 +++++- glm/core/func_integer.inl | 5 +++-- glm/core/func_packing.inl | 12 +++++++++--- glm/gtx/bit.inl | 4 ++-- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/glm/core/func_exponential.inl b/glm/core/func_exponential.inl index 9c03129e..e8ff4cfe 100644 --- a/glm/core/func_exponential.inl +++ b/glm/core/func_exponential.inl @@ -179,7 +179,11 @@ namespace detail genType xhalf(tmp * genType(0.5f)); genUType i = *reinterpret_cast(const_cast(&v)); i = genUType(0x5f375a86) - (i >> genUType(1)); - tmp = *reinterpret_cast(&i); + // tmp = *reinterpret_cast(&i); + { + genType* ptr(reinterpret_cast(&i)); + tmp = *ptr; + } tmp = tmp * (genType(1.5f) - xhalf * tmp * tmp); return tmp; } diff --git a/glm/core/func_integer.inl b/glm/core/func_integer.inl index 370e7770..b18696bd 100644 --- a/glm/core/func_integer.inl +++ b/glm/core/func_integer.inl @@ -172,7 +172,8 @@ namespace glm uint64 Value64 = static_cast(x) * static_cast(y); msb = *(reinterpret_cast(&Value64) + 1); - lsb = reinterpret_cast(Value64); + //lsb = reinterpret_cast(Value64); + lsb = *(reinterpret_cast(Value64)); } template <> @@ -231,7 +232,7 @@ namespace glm int64 Value64 = static_cast(x) * static_cast(y); msb = *(reinterpret_cast(&Value64) + 1); - lsb = reinterpret_cast(Value64); + // lsb = reinterpret_cast(Value64); } template <> diff --git a/glm/core/func_packing.inl b/glm/core/func_packing.inl index 7e26b91c..47b84733 100644 --- a/glm/core/func_packing.inl +++ b/glm/core/func_packing.inl @@ -35,7 +35,9 @@ namespace glm GLM_FUNC_QUALIFIER uint packUnorm2x16(vec2 const & v) { u16vec2 Topack(round(clamp(v, 0.0f, 1.0f) * 65535.0f)); - return reinterpret_cast(Topack); + // return reinterpret_cast(Topack); + uint* ptr(reinterpret_cast(&Topack)); + return *ptr; } GLM_FUNC_QUALIFIER vec2 unpackUnorm2x16(uint const & p) @@ -47,7 +49,9 @@ namespace glm GLM_FUNC_QUALIFIER uint packSnorm2x16(vec2 const & v) { i16vec2 Topack(round(clamp(v ,-1.0f, 1.0f) * 32767.0f)); - return reinterpret_cast(Topack); + // return reinterpret_cast(Topack); + uint* ptr(reinterpret_cast(&Topack)); + return *ptr; } GLM_FUNC_QUALIFIER vec2 unpackSnorm2x16(uint const & p) @@ -100,7 +104,9 @@ namespace glm detail::toFloat16(v.x), detail::toFloat16(v.y)); - return *reinterpret_cast(&Unpack); + //return *reinterpret_cast(&Unpack); + uint* ptr(reinterpret_cast(&Unpack)); + return *ptr; } GLM_FUNC_QUALIFIER vec2 unpackHalf2x16(uint const & v) diff --git a/glm/gtx/bit.inl b/glm/gtx/bit.inl index 53ac2954..571baf25 100644 --- a/glm/gtx/bit.inl +++ b/glm/gtx/bit.inl @@ -551,7 +551,7 @@ namespace glm assert(ToBit <= sizeof(genIUType) * std::size_t(8)); genIUType Result = Value; - for(std::size_t i = 0; i <= ToBit; ++i) + for(signed i = 0; i <= ToBit; ++i) Result |= (1 << i); return Result; } @@ -568,7 +568,7 @@ namespace glm assert(ToBit <= sizeof(genIUType) * std::size_t(8)); genIUType Result = Value; - for(std::size_t i = 0; i <= ToBit; ++i) + for(signed i = 0; i <= ToBit; ++i) Result &= ~(1 << i); return Result; }