Enable our default ASan flags on macOS

Except for the leak detection (Clang complains it's not supported there),
for which I have corrected the comment and its location.
This commit is contained in:
ISSOtm
2026-09-19 23:30:35 +02:00
committed by Eldred Habert
parent b7f6c641f1
commit bb0fc08980
+4 -3
View File
@@ -4,19 +4,20 @@
#include "helpers.hpp"
// We do not build `make develop` with `-fsanitize=leak` because macOS clang++ does not support it.
// Instead, we enable ASan (`-fsanitize=address`) to check for memory leaks in all four programs.
#ifdef __clang__
#if __has_feature(address_sanitizer) && !defined(__SANITIZE_ADDRESS__)
#define __SANITIZE_ADDRESS__
#endif
#endif
#if !defined(NDEBUG) && defined(__SANITIZE_ADDRESS__) && !defined(__APPLE__)
#if !defined(NDEBUG) && defined(__SANITIZE_ADDRESS__)
extern "C" {
char const *__asan_default_options(void) {
return ":check_initialization_order=1"
":detect_invalid_pointer_pairs=2"
// `detect_leaks` is not supported on macOS.
#ifndef __APPLE__
":detect_leaks=1"
#endif
":detect_stack_use_after_return=1"
// ":fast_unwind_on_malloc=0" // Enable this if ASan outputs bad backtraces
":print_legend=0"