fixed: warning wrt. strict aliasing on gcc 4.8.2/clang3.3

This commit is contained in:
jan p springer 2014-04-14 00:13:20 +01:00
parent ae691ce39a
commit 37e5868200
4 changed files with 19 additions and 8 deletions

View File

@ -179,7 +179,11 @@ namespace detail
genType xhalf(tmp * genType(0.5f)); genType xhalf(tmp * genType(0.5f));
genUType i = *reinterpret_cast<genUType*>(const_cast<genType*>(&v)); genUType i = *reinterpret_cast<genUType*>(const_cast<genType*>(&v));
i = genUType(0x5f375a86) - (i >> genUType(1)); i = genUType(0x5f375a86) - (i >> genUType(1));
tmp = *reinterpret_cast<genType*>(&i); // tmp = *reinterpret_cast<genType*>(&i);
{
genType* ptr(reinterpret_cast<genType*>(&i));
tmp = *ptr;
}
tmp = tmp * (genType(1.5f) - xhalf * tmp * tmp); tmp = tmp * (genType(1.5f) - xhalf * tmp * tmp);
return tmp; return tmp;
} }

View File

@ -172,7 +172,8 @@ namespace glm
uint64 Value64 = static_cast<uint64>(x) * static_cast<uint64>(y); uint64 Value64 = static_cast<uint64>(x) * static_cast<uint64>(y);
msb = *(reinterpret_cast<uint32*>(&Value64) + 1); msb = *(reinterpret_cast<uint32*>(&Value64) + 1);
lsb = reinterpret_cast<uint32&>(Value64); //lsb = reinterpret_cast<uint32&>(Value64);
lsb = *(reinterpret_cast<uint32*>(Value64));
} }
template <> template <>
@ -231,7 +232,7 @@ namespace glm
int64 Value64 = static_cast<int64>(x) * static_cast<int64>(y); int64 Value64 = static_cast<int64>(x) * static_cast<int64>(y);
msb = *(reinterpret_cast<int32*>(&Value64) + 1); msb = *(reinterpret_cast<int32*>(&Value64) + 1);
lsb = reinterpret_cast<int32&>(Value64); // lsb = reinterpret_cast<int32&>(Value64);
} }
template <> template <>

View File

@ -35,7 +35,9 @@ namespace glm
GLM_FUNC_QUALIFIER uint packUnorm2x16(vec2 const & v) GLM_FUNC_QUALIFIER uint packUnorm2x16(vec2 const & v)
{ {
u16vec2 Topack(round(clamp(v, 0.0f, 1.0f) * 65535.0f)); u16vec2 Topack(round(clamp(v, 0.0f, 1.0f) * 65535.0f));
return reinterpret_cast<uint&>(Topack); // return reinterpret_cast<uint&>(Topack);
uint* ptr(reinterpret_cast<uint*>(&Topack));
return *ptr;
} }
GLM_FUNC_QUALIFIER vec2 unpackUnorm2x16(uint const & p) GLM_FUNC_QUALIFIER vec2 unpackUnorm2x16(uint const & p)
@ -47,7 +49,9 @@ namespace glm
GLM_FUNC_QUALIFIER uint packSnorm2x16(vec2 const & v) GLM_FUNC_QUALIFIER uint packSnorm2x16(vec2 const & v)
{ {
i16vec2 Topack(round(clamp(v ,-1.0f, 1.0f) * 32767.0f)); i16vec2 Topack(round(clamp(v ,-1.0f, 1.0f) * 32767.0f));
return reinterpret_cast<uint32&>(Topack); // return reinterpret_cast<uint32&>(Topack);
uint* ptr(reinterpret_cast<uint*>(&Topack));
return *ptr;
} }
GLM_FUNC_QUALIFIER vec2 unpackSnorm2x16(uint const & p) GLM_FUNC_QUALIFIER vec2 unpackSnorm2x16(uint const & p)
@ -100,7 +104,9 @@ namespace glm
detail::toFloat16(v.x), detail::toFloat16(v.x),
detail::toFloat16(v.y)); detail::toFloat16(v.y));
return *reinterpret_cast<uint*>(&Unpack); //return *reinterpret_cast<uint*>(&Unpack);
uint* ptr(reinterpret_cast<uint*>(&Unpack));
return *ptr;
} }
GLM_FUNC_QUALIFIER vec2 unpackHalf2x16(uint const & v) GLM_FUNC_QUALIFIER vec2 unpackHalf2x16(uint const & v)

View File

@ -551,7 +551,7 @@ namespace glm
assert(ToBit <= sizeof(genIUType) * std::size_t(8)); assert(ToBit <= sizeof(genIUType) * std::size_t(8));
genIUType Result = Value; genIUType Result = Value;
for(std::size_t i = 0; i <= ToBit; ++i) for(signed i = 0; i <= ToBit; ++i)
Result |= (1 << i); Result |= (1 << i);
return Result; return Result;
} }
@ -568,7 +568,7 @@ namespace glm
assert(ToBit <= sizeof(genIUType) * std::size_t(8)); assert(ToBit <= sizeof(genIUType) * std::size_t(8));
genIUType Result = Value; genIUType Result = Value;
for(std::size_t i = 0; i <= ToBit; ++i) for(signed i = 0; i <= ToBit; ++i)
Result &= ~(1 << i); Result &= ~(1 << i);
return Result; return Result;
} }