diff --git a/libcxx/src/new.cpp b/libcxx/src/new.cpp --- a/libcxx/src/new.cpp +++ b/libcxx/src/new.cpp @@ -55,7 +55,10 @@ #if !defined(__GLIBCXX__) && \ !defined(_LIBCPP_ABI_VCRUNTIME) && \ - !defined(_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS) + !defined(_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS) && \ + !__has_feature(address_sanitizer) && \ + !__has_feature(hwaddress_sanitizer) && \ + !__has_feature(thread_sanitizer) // Implement all new and delete operators as weak definitions // in this shared library, so that they can be overridden by programs diff --git a/libcxxabi/src/stdlib_new_delete.cpp b/libcxxabi/src/stdlib_new_delete.cpp --- a/libcxxabi/src/stdlib_new_delete.cpp +++ b/libcxxabi/src/stdlib_new_delete.cpp @@ -17,6 +17,11 @@ #error The _THROW_BAD_ALLOC, _NOEXCEPT, and _LIBCXXABI_WEAK libc++ macros must \ already be defined by libc++. #endif + +#if !__has_feature(address_sanitizer) && \ + !__has_feature(hwaddress_sanitizer) && \ + !__has_feature(thread_sanitizer) + // Implement all new and delete operators as weak definitions // in this shared library, so that they can be overridden by programs // that define non-weak copies of the functions. @@ -259,4 +264,6 @@ ::operator delete[](ptr, alignment); } +#endif + #endif // !_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION