[libcxx-commits] [libcxx] [libc++] Use correct size for deallocation of arrays in shared_ptr (PR #68233)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Oct 4 15:27:11 PDT 2023
================
@@ -1137,7 +1137,8 @@ struct __unbounded_array_control_block<_Tp[], _Alloc> : __shared_weak_count
__alloc_.~_Alloc();
size_t __size = __unbounded_array_control_block::__bytes_for(__count_);
_AlignedStorage* __storage = reinterpret_cast<_AlignedStorage*>(this);
- allocator_traits<_StorageAlloc>::deallocate(__tmp, _PointerTraits::pointer_to(*__storage), __size);
+ allocator_traits<_StorageAlloc>::deallocate(
+ __tmp, _PointerTraits::pointer_to(*__storage), __size / sizeof(_AlignedStorage));
----------------
ldionne wrote:
Is this not always `__count_ + 1`? i.e. the number of elements in the array + the size of the control block at the beginning? I guess I'm kinda confused with my own code now.
https://github.com/llvm/llvm-project/pull/68233
More information about the libcxx-commits
mailing list