Don't treat class-memaccess warning as error

Cache keys must be guaranteed to have no uninitialized bits so that they
can be compared with memcmpy() and hash values can be computed from
their raw memory representation. We do this by calling memset(this, ...)
in the Memset<T> class used as the first base class. This is safe since
no other constructor has run yet (similar to doing placement new in
zeroed out memory). GCC 8.2's class-memset warning should thus not be
treated as an error.

Bug: b/135744933
Bug: b/134932616
Change-Id: I378b663281b1737359330c29c8c73934e7dd20f7
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/33368
Tested-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 087a6d7..5fae661 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -339,6 +339,15 @@
         "-Wmissing-braces"
     )
 
+    if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
+        if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8)
+            list(APPEND SWIFTSHADER_COMPILE_OPTIONS
+                # Warnings that should not be treated as errors:
+                "-Wno-error=class-memaccess"  # TODO(b/134932616): Reliably initializing cache keys currently requires memset().
+            )
+        endif()
+    endif()
+
     if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
         list(APPEND SWIFTSHADER_COMPILE_OPTIONS
             "-Wunused-lambda-capture"
diff --git a/src/Device/LRUCache.hpp b/src/Device/LRUCache.hpp
index 4fc3561..487d2a7 100644
--- a/src/Device/LRUCache.hpp
+++ b/src/Device/LRUCache.hpp
@@ -48,7 +48,7 @@
 	};
 
 	// Helper class for clearing the memory of objects at construction.
-	// Useful as the first base class or cache keys which may contain padding bytes or bits otherwise left uninitialized.
+	// Useful as the first base class of cache keys which may contain padding bytes or bits otherwise left uninitialized.
 	template<class T>
 	struct Memset
 	{