Fix aliasing

This commit is contained in:
posophe 2015-11-16 15:26:32 +01:00
parent 0af2e05b1b
commit 3623e6bc4d

View File

@ -609,7 +609,9 @@ namespace detail
GLM_FUNC_QUALIFIER int floatBitsToInt(float const & v) GLM_FUNC_QUALIFIER int floatBitsToInt(float const & v)
{ {
return reinterpret_cast<int&>(const_cast<float&>(v)); int Bits;
std::memcpy(&Bits, &v, sizeof(Bits));
return Bits;
} }
template <template <typename, precision> class vecType, precision P> template <template <typename, precision> class vecType, precision P>
@ -620,7 +622,9 @@ namespace detail
GLM_FUNC_QUALIFIER uint floatBitsToUint(float const & v) GLM_FUNC_QUALIFIER uint floatBitsToUint(float const & v)
{ {
return reinterpret_cast<uint&>(const_cast<float&>(v)); uint Bits;
std::memcpy(&Bits, &v, sizeof(Bits));
return Bits;
} }
template <template <typename, precision> class vecType, precision P> template <template <typename, precision> class vecType, precision P>
@ -631,7 +635,9 @@ namespace detail
GLM_FUNC_QUALIFIER float intBitsToFloat(int const & v) GLM_FUNC_QUALIFIER float intBitsToFloat(int const & v)
{ {
return reinterpret_cast<float&>(const_cast<int&>(v)); float Float;
std::memcpy(&Float, &v, sizeof(Float));
return Float;
} }
template <template <typename, precision> class vecType, precision P> template <template <typename, precision> class vecType, precision P>
@ -642,7 +648,9 @@ namespace detail
GLM_FUNC_QUALIFIER float uintBitsToFloat(uint const & v) GLM_FUNC_QUALIFIER float uintBitsToFloat(uint const & v)
{ {
return reinterpret_cast<float&>(const_cast<uint&>(v)); float Float;
std::memcpy(&Float, &v, sizeof(Float));
return Float;
} }
template <template <typename, precision> class vecType, precision P> template <template <typename, precision> class vecType, precision P>