[libcxx-commits] [PATCH] D62760: allocate_shared should call allocator_traits::construct

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue May 19 06:28:28 PDT 2020


ldionne requested changes to this revision.
ldionne added inline comments.
This revision now requires changes to proceed.


================
Comment at: libcxx/include/memory:3658
     __data_.second().~_Alloc();
-    __a.deallocate(_PTraits::pointer_to(*this), 1);
+    __a.deallocate(_PTraits::pointer_to(*reinterpret_cast<char*>(this)), __size);
 }
----------------
zoecarver wrote:
> ldionne wrote:
> > Can you explain why, in this patch, using `__a.deallocate(_PTraits::pointer_to(*this), 1);` is not sufficient?
> Because `_Al` is rebound to `char` type and used in `_ATraits` which is used to get the pointer type for `_PTraits` so, `_PTraits:: pointer_to ` will be expecting a `char*`.
But why do you need to rebind it to `char`?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62760/new/

https://reviews.llvm.org/D62760





More information about the libcxx-commits mailing list