Fix warning on Linux

On Linux, the compiler is throwing a warning:
warning: ‘<anonymous>’ is used uninitialized
when using:
*reinterpret_cast<const unsigned int *>(this);

Using a union silences the warning and makes the code a bit neater.

Bug: b/18368388
Change-Id: I29e6ff4b67d9d7a1adde65ec41fdb95a6e76d413
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/66728
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
Presubmit-Ready: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Commit-Queue: Alexis Hétu <sugoi@google.com>
diff --git a/src/System/Half.hpp b/src/System/Half.hpp
index d25b33e..eebad3f 100644
--- a/src/System/Half.hpp
+++ b/src/System/Half.hpp
@@ -51,10 +51,17 @@
 
 class RGB9E5
 {
-	unsigned int R : 9;
-	unsigned int G : 9;
-	unsigned int B : 9;
-	unsigned int E : 5;
+	union
+	{
+		struct
+		{
+			unsigned int R : 9;
+			unsigned int G : 9;
+			unsigned int B : 9;
+			unsigned int E : 5;
+		};
+		uint32_t packed;
+	};
 
 public:
 	RGB9E5(const float rgb[3])
@@ -111,7 +118,7 @@
 
 	operator unsigned int() const
 	{
-		return *reinterpret_cast<const unsigned int *>(this);
+		return packed;
 	}
 
 	void toRGB16F(half rgb[3]) const
@@ -127,6 +134,17 @@
 
 class R11G11B10F
 {
+	union
+	{
+		struct
+		{
+			unsigned int R : 11;
+			unsigned int G : 11;
+			unsigned int B : 10;
+		};
+		uint32_t packed;
+	};
+
 public:
 	R11G11B10F(const float rgb[3])
 	{
@@ -137,7 +155,7 @@
 
 	operator unsigned int() const
 	{
-		return *reinterpret_cast<const unsigned int *>(this);
+		return packed;
 	}
 
 	void toRGB16F(half rgb[3]) const
@@ -314,11 +332,6 @@
 			return ((float32Val + 0x1FFFF + ((float32Val >> 18) & 1)) >> 18) & float10BitMask;
 		}
 	}
-
-private:
-	unsigned int R : 11;
-	unsigned int G : 11;
-	unsigned int B : 10;
 };
 
 }  // namespace sw