Commit f8b4a6e25a3cd914d0abe6be5907a75d50a5f8fb

Christian Rauch 2021-01-31T19:09:25

cmake: enable AddressSanitizer in Debug builds

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 40ddc0d..cf3aa20 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2323,6 +2323,23 @@ if(SDL_STATIC)
   endif()
 endif()
 
+set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} \
+    -fsanitize=address \
+    -fsanitize=bool \
+    -fsanitize=bounds \
+    -fsanitize=enum \
+    -fsanitize=float-cast-overflow \
+    -fsanitize=float-divide-by-zero \
+    -fsanitize=nonnull-attribute \
+    -fsanitize=returns-nonnull-attribute \
+    -fsanitize=signed-integer-overflow \
+    -fsanitize=undefined \
+    -fsanitize=vla-bound \
+    -fno-sanitize=alignment \
+    -fsanitize=leak \
+    -fsanitize=object-size \
+")
+
 ##### Tests #####
 
 if(SDL_TEST)