aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2021-06-10 11:19:11 -0500
committerluigi1111 <luigi1111w@gmail.com>2021-06-10 11:19:11 -0500
commitf85cab675001b038b1ed5d9f429d4999b557f0dd (patch)
tree1b9f5657024d062fc9726220164d93b45a394d2d
parentMerge pull request #7416 (diff)
parentWarnings: add warnings as errors: 'switch' & 'return-type' (diff)
downloadmonero-f85cab675001b038b1ed5d9f429d4999b557f0dd.tar.xz
Merge pull request #7481
430b758 Warnings: add warnings as errors: 'switch' & 'return-type' (mj-xmr)
-rw-r--r--CMakeLists.txt7
1 files changed, 7 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7d5c62cf0..b35eb2b7a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -805,6 +805,13 @@ else()
add_linker_flag_if_supported(-Wl,--high-entropy-va LD_SECURITY_FLAGS)
endif()
+ # Warnings, that when ignored are so severe, that they can segfault or even UB any application.
+ # Treat them as errors.
+ add_c_flag_if_supported( -Werror=switch C_SECURITY_FLAGS)
+ add_cxx_flag_if_supported(-Werror=switch CXX_SECURITY_FLAGS)
+ add_c_flag_if_supported( -Werror=return-type C_SECURITY_FLAGS)
+ add_cxx_flag_if_supported(-Werror=return-type CXX_SECURITY_FLAGS)
+
message(STATUS "Using C security hardening flags: ${C_SECURITY_FLAGS}")
message(STATUS "Using C++ security hardening flags: ${CXX_SECURITY_FLAGS}")
message(STATUS "Using linker security hardening flags: ${LD_SECURITY_FLAGS}")