Fix null dereference in OFFSET macro

Applied same fix as done in 0e6a044 for the same macro in
src/Common/Types.hpp (including copying the comment verbatim).

Change-Id: I822db18f19a5473d9cf56ab57339ae91e96f458e
Bug: b/155089897
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/44508
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Tested-by: James Price <jrprice@google.com>
diff --git a/src/System/Types.hpp b/src/System/Types.hpp
index 165df56..f0f3923 100644
--- a/src/System/Types.hpp
+++ b/src/System/Types.hpp
@@ -201,7 +201,10 @@
 	return vector(f, f, f, f);
 }
 
-#define OFFSET(s, m) (int)(size_t) & reinterpret_cast<const volatile char &>((((s *)0)->m))
+// The OFFSET macro is a generalization of the offsetof() macro defined in <cstddef>.
+// It allows e.g. getting the offset of array elements, even when indexed dynamically.
+// We cast the address '32' and subtract it again, because null-dereference is undefined behavior.
+#define OFFSET(s, m) ((int)(size_t) & reinterpret_cast<const volatile char &>((((s *)32)->m)) - 32)
 
 }  // namespace sw