diff --git a/libcxx/include/memory b/libcxx/include/memory --- a/libcxx/include/memory +++ b/libcxx/include/memory @@ -2593,7 +2593,7 @@ _TpAlloc __tmp(*__get_alloc()); allocator_traits<_TpAlloc>::construct(__tmp, __get_elem(), _VSTD::forward<_Args>(__args)...); #else - ::new ((void*)__get_elem()) _Tp(_VSTD::forward<_Args>(__args)...); + ::new (__storage_.__get_elem_for_new()) _Tp(_VSTD::forward<_Args>(__args)...); #endif } @@ -2653,6 +2653,11 @@ _Tp *__elem = reinterpret_cast<_Tp*>(__second); return __elem; } + void *__get_elem_for_new() _NOEXCEPT { + _CompressedPair *__as_pair = reinterpret_cast<_CompressedPair*>(__blob_); + typename _CompressedPair::_Base2* __second = _CompressedPair::__get_second_base(__as_pair); + return (void*)__second; + } }; static_assert(_LIBCPP_ALIGNOF(_Storage) == _LIBCPP_ALIGNOF(_CompressedPair), "");