[libcxx-commits] [libcxx] bab7486 - Disable CFI in __get_elem to allow casting a pointer to uninitialized memory

Reid Kleckner via libcxx-commits libcxx-commits at lists.llvm.org
Tue Feb 2 12:39:31 PST 2021


Author: Reid Kleckner
Date: 2021-02-02T12:39:24-08:00
New Revision: bab74864168bb5e28ecbc0294fe1095d8da7f569

URL: https://github.com/llvm/llvm-project/commit/bab74864168bb5e28ecbc0294fe1095d8da7f569
DIFF: https://github.com/llvm/llvm-project/commit/bab74864168bb5e28ecbc0294fe1095d8da7f569.diff

LOG: Disable CFI in __get_elem to allow casting a pointer to uninitialized memory

Fixes usage of shared_ptr with CFI enabled, which is llvm.org/pr48993.

Differential Revision: https://reviews.llvm.org/D95827

Added: 
    

Modified: 
    libcxx/include/memory

Removed: 
    


################################################################################
diff  --git a/libcxx/include/memory b/libcxx/include/memory
index a00916c8c03f..39d0f5bee6a5 100644
--- a/libcxx/include/memory
+++ b/libcxx/include/memory
@@ -2647,7 +2647,7 @@ private:
             _Alloc *__alloc = reinterpret_cast<_Alloc*>(__first);
             return __alloc;
         }
-        _Tp* __get_elem() _NOEXCEPT {
+        _LIBCPP_NO_CFI _Tp* __get_elem() _NOEXCEPT {
             _CompressedPair *__as_pair = reinterpret_cast<_CompressedPair*>(__blob_);
             typename _CompressedPair::_Base2* __second = _CompressedPair::__get_second_base(__as_pair);
             _Tp *__elem = reinterpret_cast<_Tp*>(__second);


        


More information about the libcxx-commits mailing list