From 3623e6bc4dd3d9c366bc5c7765a0136a7c58f0ed Mon Sep 17 00:00:00 2001
From: posophe
Date: Mon, 16 Nov 2015 15:26:32 +0100
Subject: [PATCH] Fix aliasing
---
glm/detail/func_common.inl | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/glm/detail/func_common.inl b/glm/detail/func_common.inl
index 83252de4..479d9b6a 100644
--- a/glm/detail/func_common.inl
+++ b/glm/detail/func_common.inl
@@ -609,7 +609,9 @@ namespace detail
GLM_FUNC_QUALIFIER int floatBitsToInt(float const & v)
{
- return reinterpret_cast(const_cast(v));
+ int Bits;
+ std::memcpy(&Bits, &v, sizeof(Bits));
+ return Bits;
}
template class vecType, precision P>
@@ -620,7 +622,9 @@ namespace detail
GLM_FUNC_QUALIFIER uint floatBitsToUint(float const & v)
{
- return reinterpret_cast(const_cast(v));
+ uint Bits;
+ std::memcpy(&Bits, &v, sizeof(Bits));
+ return Bits;
}
template class vecType, precision P>
@@ -631,7 +635,9 @@ namespace detail
GLM_FUNC_QUALIFIER float intBitsToFloat(int const & v)
{
- return reinterpret_cast(const_cast(v));
+ float Float;
+ std::memcpy(&Float, &v, sizeof(Float));
+ return Float;
}
template class vecType, precision P>
@@ -642,7 +648,9 @@ namespace detail
GLM_FUNC_QUALIFIER float uintBitsToFloat(uint const & v)
{
- return reinterpret_cast(const_cast(v));
+ float Float;
+ std::memcpy(&Float, &v, sizeof(Float));
+ return Float;
}
template class vecType, precision P>