Author: pcc Date: Wed Aug 15 10:49:30 2018 New Revision: 339797 URL: http://llvm.org/viewvc/llvm-project?rev=339797&view=rev Log: 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 Modified: libcxx/trunk/include/memory Modified: libcxx/trunk/include/memory URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=339797&r1=339796&r2=339797&view=diff ============================================================================== --- libcxx/trunk/include/memory (original) +++ libcxx/trunk/include/memory Wed Aug 15 10:49:30 2018 @@ -5631,8 +5631,11 @@ struct __temp_value { _Tp & get() { return *__addr(); } template<class... _Args> - __temp_value(_Alloc &__alloc, _Args&& ... __args) : __a(__alloc) - { _Traits::construct(__a, __addr(), _VSTD::forward<_Args>(__args)...); } + _LIBCPP_NO_CFI + __temp_value(_Alloc &__alloc, _Args&& ... __args) : __a(__alloc) { + _Traits::construct(__a, reinterpret_cast<_Tp*>(addressof(__v)), + _VSTD::forward<_Args>(__args)...); + } ~__temp_value() { _Traits::destroy(__a, __addr()); } }; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits