Skip to content

Conversation

philnik777
Copy link
Contributor

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 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.
@philnik777 philnik777 marked this pull request as ready for review August 6, 2025 15:50
@philnik777 philnik777 requested a review from a team as a code owner August 6, 2025 15:50
@philnik777 philnik777 merged commit b1482aa into llvm:main Aug 6, 2025
75 of 78 checks passed
@philnik777 philnik777 deleted the fix_tree_downcast branch August 6, 2025 15:50
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Aug 6, 2025
@llvmbot
Copy link
Member

llvmbot commented Aug 6, 2025

@llvm/pr-subscribers-libcxx

Author: Nikolas Klauser (philnik777)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/152285.diff

1 Files Affected:

  • (modified) libcxx/include/__tree (+3-2)
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;
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants