From d2ecb8937c02d72779c1ee74d85973ffda9d01c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Tue, 13 Jan 2026 23:39:37 +0100 Subject: [PATCH] Use allocate_aligned in cached implementation and the allocator_v1 testing utility to support overaligned types. --- .../boost/interprocess/allocators/detail/allocator_common.hpp | 3 ++- test/allocator_v1.hpp | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/boost/interprocess/allocators/detail/allocator_common.hpp b/include/boost/interprocess/allocators/detail/allocator_common.hpp index 62dc6b7..54cbe5c 100644 --- a/include/boost/interprocess/allocators/detail/allocator_common.hpp +++ b/include/boost/interprocess/allocators/detail/allocator_common.hpp @@ -739,7 +739,8 @@ class cached_allocator_impl ret = m_cache.cached_allocation(); } else{ - ret = this->get_segment_manager()->allocate(count*sizeof(T)); + ret = this->get_segment_manager()->allocate_aligned + (count*sizeof(T), boost::container::dtl::alignment_of::value); } return pointer(static_cast(ret)); } diff --git a/test/allocator_v1.hpp b/test/allocator_v1.hpp index bf87a67..6bf7a3b 100644 --- a/test/allocator_v1.hpp +++ b/test/allocator_v1.hpp @@ -118,7 +118,9 @@ class allocator_v1 if(size_overflows(count)){ throw bad_alloc(); } - (void)hint; return pointer(static_cast(mp_mngr->allocate(count*sizeof(T)))); + (void)hint; + return pointer(static_cast + (mp_mngr->allocate_aligned(count*sizeof(T), , boost::container::dtl::alignment_of::value))); } //!Deallocates memory previously allocated. Never throws