From 2a649bd074cfdd14fd694eef05d5c3bdc85e0208 Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Tue, 15 Sep 2020 00:53:07 +0200 Subject: [PATCH] Suppress GCC8+ warnings about memcpy()/memset() on classes .. with "no trivial copy-assignment". All the cases I checked were harmless; as long as a class has no vptr or owns memory (or other resources) that need to be handled properly in the destructor, memcpy() and memset() aren't too dangerous. --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 737de30..9ca3fab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -125,6 +125,14 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang") add_compile_options(-Wno-switch) add_compile_options(-Wno-strict-overflow) add_compile_options(-Wno-format-security) + + if(CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0) + # ‘void* memset(void*, int, size_t)’ clearing an object of type ‘struct refSound_t’ with no trivial copy-assignment; use assignment or value-initialization instead + # ‘void* memcpy(void*, const void*, size_t)’ writing to an object of type ‘class idDrawVert’ with no trivial copy-assignment; use copy-assignment or copy-initialization instead + # etc - I don't care, all the cases I've checked were safe and I'm not gonna add (void*) casts in 1000 places + # (that would make merging new mods painful) + add_compile_options(-Wno-class-memaccess) + endif() CHECK_CXX_COMPILER_FLAG("-Woverloaded-virtual" cxx_has_Woverload_virtual) if(cxx_has_Woverload_virtual)