From 4b7f784d1bcf3a9eb660aaabafaacd80957d2de2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Sat, 21 Nov 2020 01:44:15 +0100 Subject: [PATCH] Disable -Wstringop-truncation warnings Disable -Wstringop-truncation warnings as they result in many false positives. In most (all?) cases where std::strncpy is used, we want to fill the entire buffer or match emulated code that also ignores the null terminator, so the warnings are not useful. Given that Dolphin itself mostly uses std::string, they do not really help catch any bugs. --- Source/CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index df91f4b668..3b70daf4f2 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -84,6 +84,15 @@ else() check_and_add_flag(INIT_SELF -Winit-self) check_and_add_flag(MISSING_DECLARATIONS -Wmissing-declarations) check_and_add_flag(MISSING_VARIABLE_DECLARATIONS -Wmissing-variable-declarations) + + # Disable -Wstringop-truncation warnings as they result in many false positives. + # In most (all?) cases where std::strncpy is used, we want to fill the entire buffer + # or match emulated code that also ignores the null terminator, so the warnings are not useful. + # Given that Dolphin itself mostly uses std::string, they do not really help catch any bugs. + check_cxx_compiler_flag(-Wstringop-truncation HAS_STRINGOP_TRUNCATION_WARNING) + if (HAS_STRINGOP_TRUNCATION_WARNING) + check_and_add_flag(NO_STRINGOP_TRUNCATION -Wno-stringop-truncation) + endif() endif() # These aren't actually needed for C11/C++11