Forráskód Böngészése

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

jan p springer 11 éve
szülő
commit
37e5868200

+ 5 - 1
glm/core/func_exponential.inl

@@ -179,7 +179,11 @@ namespace detail
 			genType xhalf(tmp * genType(0.5f));
 			genUType i = *reinterpret_cast<genUType*>(const_cast<genType*>(&v));
 			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);
 			return tmp;
 		}

+ 3 - 2
glm/core/func_integer.inl

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

+ 9 - 3
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<uint&>(Topack);
+		// return reinterpret_cast<uint&>(Topack);
+    uint* ptr(reinterpret_cast<uint*>(&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<uint32&>(Topack);
+		// return reinterpret_cast<uint32&>(Topack);
+    uint* ptr(reinterpret_cast<uint*>(&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<uint*>(&Unpack);
+		//return *reinterpret_cast<uint*>(&Unpack);
+    uint* ptr(reinterpret_cast<uint*>(&Unpack));
+    return *ptr;
 	}
 
 	GLM_FUNC_QUALIFIER vec2 unpackHalf2x16(uint const & v)

+ 2 - 2
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;
 	}