[libc++] Consistently replace `::new(__p) T` with `::new ((void*)__p) T`. NFCI.
Everywhere, normalize the whitespace to `::new (EXPR) T`.
Everywhere, normalize the spelling of the cast to `(void*)EXPR`.
Without the cast to `(void*)`, the expression triggers ADL on GCC.
(I think this is a GCC bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98249)
Even if it doesn't trigger ADL, it still seems incorrect to use any argument
that's not exactly `(void*)` because that opens the possibility of overload
resolution picking a user-defined overload of `operator new`, which would be
wrong.
Differential Revision: https://reviews.llvm.org/D93153
GitOrigin-RevId: be4c657b010c3fd850ca5cfcee0f96b464740523
diff --git a/include/functional b/include/functional
index ffcff35..6d3d905 100644
--- a/include/functional
+++ b/include/functional
@@ -1609,7 +1609,7 @@
__builtin_new_allocator::__holder_t __hold =
__builtin_new_allocator::__allocate_type<__default_alloc_func>(1);
__default_alloc_func* __res =
- ::new (__hold.get()) __default_alloc_func(__f_);
+ ::new ((void*)__hold.get()) __default_alloc_func(__f_);
(void)__hold.release();
return __res;
}
@@ -1700,7 +1700,7 @@
void
__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone(__base<_Rp(_ArgTypes...)>* __p) const
{
- ::new (__p) __func(__f_.__target(), __f_.__get_allocator());
+ ::new ((void*)__p) __func(__f_.__target(), __f_.__get_allocator());
}
template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
@@ -2154,7 +2154,7 @@
} else {
__builtin_new_allocator::__holder_t __hold =
__builtin_new_allocator::__allocate_type<_Fun>(1);
- __buf_.__large = ::new (__hold.get()) _Fun(_VSTD::move(__f));
+ __buf_.__large = ::new ((void*)__hold.get()) _Fun(_VSTD::move(__f));
(void)__hold.release();
}
}
@@ -2286,7 +2286,7 @@
}
virtual void __clone(__base<_Rp(_ArgTypes...)>* __p) const {
- ::new (__p) __func(__f_);
+ ::new ((void*)__p) __func(__f_);
}
virtual void destroy() _NOEXCEPT {