From c5f9afe6448896294ea08a568867d5e580126cab Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Mon, 4 May 2026 11:02:08 -0700 Subject: [PATCH 1/2] Cleaner structure of is_asan_ check --- src/init.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/init.c b/src/init.c index 97a50f4a..220468fe 100644 --- a/src/init.c +++ b/src/init.c @@ -43,13 +43,9 @@ SEXP gcov_flush(void) { SEXP is_asan_() { -#if defined(__has_feature) -#if __has_feature(address_sanitizer) // for clang -#define __SANITIZE_ADDRESS__ // GCC already sets this -#endif -#endif - -#ifdef __SANITIZE_ADDRESS__ +#if defined(__SANITIZE_ADDRESS__) + return Rf_ScalarLogical(1); +#elif defined(__has_feature) && __has_feature(address_sanitizer) // for clang return Rf_ScalarLogical(1); #else return Rf_ScalarLogical(0); From 3acf606acdfc6bee33490f52eb02653152593465 Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Mon, 4 May 2026 11:24:17 -0700 Subject: [PATCH 2/2] fun with preprocessor syntax --- src/init.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/init.c b/src/init.c index 220468fe..17e6718c 100644 --- a/src/init.c +++ b/src/init.c @@ -43,9 +43,14 @@ SEXP gcov_flush(void) { SEXP is_asan_() { + +#ifndef __has_feature + #define __has_feature(x) 0 +#endif + #if defined(__SANITIZE_ADDRESS__) return Rf_ScalarLogical(1); -#elif defined(__has_feature) && __has_feature(address_sanitizer) // for clang +#elif __has_feature(address_sanitizer) // for clang return Rf_ScalarLogical(1); #else return Rf_ScalarLogical(0);