[libcxx-commits] [libcxx] [libc++] Fix incorrect down-cast in __tree (PR #152181)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Tue Aug 5 10:21:27 PDT 2025


https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/152181

None

>From c64f63fbef7bded0459294fcd32134cf512d47b6 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Tue, 5 Aug 2025 19:21:06 +0200
Subject: [PATCH] [libc++] Fix incorrect down-cast in __tree

---
 libcxx/include/__tree | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libcxx/include/__tree b/libcxx/include/__tree
index 1b1bb538029da..b25dbc7177df2 100644
--- a/libcxx/include/__tree
+++ b/libcxx/include/__tree
@@ -1445,8 +1445,9 @@ __tree<_Tp, _Compare, _Allocator>::__tree(const __tree& __t)
 
   *__root_ptr()       = static_cast<__node_base_pointer>(__copy_construct_tree(__t.__root()));
   __root()->__parent_ = __end_node();
-  __begin_node_ = static_cast<__end_node_pointer>(std::__tree_min(static_cast<__node_base_pointer>(__end_node())));
-  __size_       = __t.size();
+  __begin_node_ =
+      static_cast<__end_node_pointer>(std::__tree_min(static_cast<__node_base_pointer>(__end_node()->__left_)));
+  __size_ = __t.size();
 }
 
 template <class _Tp, class _Compare, class _Allocator>



More information about the libcxx-commits mailing list