[libc++] Fix incorrect down cast in __tree::operator= (#152285)

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.
This commit is contained in:
Nikolas Klauser 2025-08-06 17:50:53 +02:00 committed by GitHub
parent c9eff91ef1
commit b1482aa91b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1388,8 +1388,9 @@ __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())));
__size_ = __t.size();
__begin_node_ =
__end_node()->__left_ ? static_cast<__end_node_pointer>(std::__tree_min(__end_node()->__left_)) : __end_node();
__size_ = __t.size();
return *this;
}