From e19e121cf4aa1ccd0028fe77bb00914913b8268a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Fri, 26 Dec 2025 14:17:45 +0100 Subject: [PATCH] Make an exception to MacOs platforms, where system malloc only aligns to 8 bytes, even in ARM64. --- .../container/detail/operator_new_helpers.hpp | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/include/boost/container/detail/operator_new_helpers.hpp b/include/boost/container/detail/operator_new_helpers.hpp index 14e7cde..1bfd69d 100644 --- a/include/boost/container/detail/operator_new_helpers.hpp +++ b/include/boost/container/detail/operator_new_helpers.hpp @@ -32,26 +32,18 @@ namespace dtl { BOOST_CONTAINER_FORCEINLINE bool operator_new_raw_overaligned(std::size_t alignment) { + //In MacOs, the default allocator can return data aligned to 8 bytes + #if defined(__APPLE__) + return alignment > 8u; //GCC-clang on Mingw-w64 has problems with malloc (MSVCRT / UCRT) alignment not matching //__STDCPP_DEFAULT_NEW_ALIGNMENT__, since HeapAlloc alignment is 8 for 32 bit targets - #if !defined(__cpp_aligned_new) || (defined(_WIN32) && !defined(_WIN64) && !defined(_MSC_VER)) - return alignment > 2u*sizeof(void*); + #elif !defined(__cpp_aligned_new) || (defined(_WIN32) && !defined(_WIN64) && !defined(_MSC_VER)) + return alignment > 2*sizeof(void*); #else return alignment > __STDCPP_DEFAULT_NEW_ALIGNMENT__; #endif } -BOOST_CONTAINER_FORCEINLINE bool operator_new_raw_overaligned_tricky() -{ - //GCC-clang on Mingw-w64 has problems with malloc (MSVCRT / UCRT) alignment not matching - //__STDCPP_DEFAULT_NEW_ALIGNMENT__, since HeapAlloc alignment is 8 for 32 bit targets - #if !defined(__cpp_aligned_new) || (defined(_WIN32) && !defined(_WIN64) && !defined(_MSC_VER)) - return true; - #else - return false; - #endif -} - BOOST_CONTAINER_FORCEINLINE void* operator_new_raw_allocate(const std::size_t size, const std::size_t alignment) { (void)alignment;