[libcxx-commits] [PATCH] D93153: [libc++] Consistently replace `::new(__p) T` with `::new ((void*)__p) T`. NFCI

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Dec 14 14:02:19 PST 2020


Quuxplusone marked 2 inline comments as done.
Quuxplusone added inline comments.


================
Comment at: libcxx/include/__functional_03:129
     unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
-    ::new (__hold.get()) __func(__f_.first(), _Alloc(__a));
+    ::new ((void*)__hold.get()) __func(__f_.first(), _Alloc(__a));
     return __hold.release();
----------------
zoecarver wrote:
> zoecarver wrote:
> > Nit: would be better to make these `static_cast`s IMHO.
> Sorry, didn't realize this already landed. No need to change it. 
No worries, I would have argued anyway. ;)
My goal is to be consistent on something that we can cut and paste everywhere, so I would want to use `static_cast` here //only if// you are willing to use `static_cast` everywhere.

For this spot in particular, are you worried that the allocator's pointers might be fancy? If that's the issue, then I think we actually need something like `::new ((void*)_VSTD::addressof(*__hold.get())) __func(...)`. The kind of cast isn't the problem; it's that no such conversion might exist at all. (And my recent patch-series has taught me that `*__hold.get()` avoids ADL when `*__hold` would trigger it. Gross, right?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93153



More information about the libcxx-commits mailing list