[libc++] Fix incorrect down cast in __tree::operator=#152285
Merged
philnik777 merged 1 commit intollvm:mainfrom Aug 6, 2025
Merged
[libc++] Fix incorrect down cast in __tree::operator=#152285philnik777 merged 1 commit intollvm:mainfrom
philnik777 merged 1 commit intollvm:mainfrom
Conversation
This has been introduced by llvm#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.
Member
|
@llvm/pr-subscribers-libcxx Author: Nikolas Klauser (philnik777) ChangesThis has been introduced by #151304. This problem is diagnosed by UBSan Full diff: https://github.com/llvm/llvm-project/pull/152285.diff 1 Files Affected:
diff --git a/libcxx/include/__tree b/libcxx/include/__tree
index 6ca1a623536f2..74b20d5b6f814 100644
--- a/libcxx/include/__tree
+++ b/libcxx/include/__tree
@@ -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;
}
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.