From a2f2745035414a4541ee0413bad9667c50c9c894 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Wed, 13 Oct 2021 17:28:48 +0900 Subject: [PATCH] glib-private: Fix MSVC build with AddressSanitizer MSVC supports AddressSanitizer as well via "/fsanitize=address" option, but __lsan_ignore_object() equivalent feature is not supported. Note that there's __declspec(no_sanitize_address) specifier which provides a similar feature but that's not runtime behavior so it's not directly applicable to g_ignore_leak() family. See also https://docs.microsoft.com/en-us/cpp/sanitizers/asan-building?view=msvc-160 --- glib/glib-private.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/glib/glib-private.h b/glib/glib-private.h index 8de380d12..1b53fccc0 100644 --- a/glib/glib-private.h +++ b/glib/glib-private.h @@ -23,8 +23,14 @@ #include "gstdioprivate.h" /* gcc defines __SANITIZE_ADDRESS__, clang sets the address_sanitizer - * feature flag */ -#if defined(__SANITIZE_ADDRESS__) || g_macro__has_feature(address_sanitizer) + * feature flag. + * + * MSVC defines __SANITIZE_ADDRESS__ as well when AddressSanitizer + * is enabled but __lsan_ignore_object() equivalent method is not supported + * See also + * https://docs.microsoft.com/en-us/cpp/sanitizers/asan-building?view=msvc-160 + */ +#if !defined(_MSC_VER) && (defined(__SANITIZE_ADDRESS__) || g_macro__has_feature(address_sanitizer)) /* * %_GLIB_ADDRESS_SANITIZER: