Skip to content

Commit b1482aa

Browse files
authored
[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.
1 parent c9eff91 commit b1482aa

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

libcxx/include/__tree

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,8 +1388,9 @@ __tree<_Tp, _Compare, _Allocator>& __tree<_Tp, _Compare, _Allocator>::operator=(
13881388
if (__root())
13891389
__root()->__parent_ = __end_node();
13901390
}
1391-
__begin_node_ = static_cast<__end_node_pointer>(std::__tree_min(static_cast<__node_base_pointer>(__end_node())));
1392-
__size_ = __t.size();
1391+
__begin_node_ =
1392+
__end_node()->__left_ ? static_cast<__end_node_pointer>(std::__tree_min(__end_node()->__left_)) : __end_node();
1393+
__size_ = __t.size();
13931394

13941395
return *this;
13951396
}

0 commit comments

Comments
 (0)