[libcxx-commits] [libcxx] 3511044 - [libc++] Fix incorrect down cast in __tree::operator=

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Wed Aug 6 03:07:38 PDT 2025


Author: Nikolas Klauser
Date: 2025-08-06T12:05:19+02:00
New Revision: 35110445081152f7f2d2a9d053bb6fa718216d7b

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

LOG: [libc++] Fix incorrect down cast in __tree::operator=

This has been introduced by #151304. This problem is diagnosed by UBSan
with optimizations enabled. Since we run UBSan only with optimizations
disabled currently, this isn't caught in our CI. We should look into
enabling UBSan with optimizations enabled to catch these sorts of issues
before landing a patch.

Added: 
    

Modified: 
    libcxx/include/__tree

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__tree b/libcxx/include/__tree
index 6ca1a623536f2..64d1436055bfe 100644
--- a/libcxx/include/__tree
+++ b/libcxx/include/__tree
@@ -1388,7 +1388,7 @@ __tree<_Tp, _Compare, _Allocator>& __tree<_Tp, _Compare, _Allocator>::operator=(
     if (__root())
       __root()->__parent_ = __end_node();
   }
-  __begin_node_ = static_cast<__end_node_pointer>(std::__tree_min(static_cast<__node_base_pointer>(__end_node())));
+  __begin_node_ = static_cast<__end_node_pointer>(std::__tree_min(__end_node()->__left_));
   __size_       = __t.size();
 
   return *this;


        


More information about the libcxx-commits mailing list