Skip to content

Commit f11c00d

Browse files
committed
libcxx: Mark __temp_value::__temp_value as _LIBCPP_NO_CFI.
This constructor needs to cast a pointer to uninitialized memory to a pointer to object type in order to call allocator_traits::construct(). This cast is not allowed when CFI cast checks are enabled. I did this instead of marking __addr() as _LIBCPP_NO_CFI so that we don't lose CFI checks on get() or the dtor. Differential Revision: https://reviews.llvm.org/D50743 llvm-svn: 339797
1 parent 070ac76 commit f11c00d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

libcxx/include/memory

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5631,8 +5631,11 @@ struct __temp_value {
56315631
_Tp & get() { return *__addr(); }
56325632

56335633
template<class... _Args>
5634-
__temp_value(_Alloc &__alloc, _Args&& ... __args) : __a(__alloc)
5635-
{ _Traits::construct(__a, __addr(), _VSTD::forward<_Args>(__args)...); }
5634+
_LIBCPP_NO_CFI
5635+
__temp_value(_Alloc &__alloc, _Args&& ... __args) : __a(__alloc) {
5636+
_Traits::construct(__a, reinterpret_cast<_Tp*>(addressof(__v)),
5637+
_VSTD::forward<_Args>(__args)...);
5638+
}
56365639

56375640
~__temp_value() { _Traits::destroy(__a, __addr()); }
56385641
};

0 commit comments

Comments
 (0)