On 13/07/20 16:45 +0800, Xi Ruoyao via Libstdc++ wrote:
The second and third patch together resolve PR 81806.
The attached patch modifies split_finish to use the subtree size we maintained
in the previous patch, resolving libstdc++/81806.
libstdc++-v3/ChangeLog:
PR libstdc++/81806
* include/ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp
(split_finish): Use maintained size, instead of calling
std::distance.
OK for trunk
--
Xi Ruoyao <xry...@mengyan1223.wang>
School of Aerospace Science and Technology, Xidian University
From 4434da1b2b45797204f4fd978dcc4fbba4b17c6e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?X=E2=84=B9=20Ruoyao?= <xry...@mengyan1223.wang>
Date: Fri, 10 Jul 2020 21:38:09 +0800
Subject: [PATCH 3/5] libstdc++: use maintained size when split pb_ds binary
search trees
libstdc++-v3/ChangeLog:
PR libstdc++/81806
* include/ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp
(split_finish): Use maintained size, instead of calling
std::distance.
---
.../ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git
a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp
b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp
index d08288f186d..fb924b4434b 100644
---
a/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp
+++
b/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp
@@ -133,7 +133,9 @@ PB_DS_CLASS_C_DEC::
split_finish(PB_DS_CLASS_C_DEC& other)
{
other.initialize_min_max();
- other.m_size = std::distance(other.begin(), other.end());
+ other.m_size = 0;
+ if (other.m_p_head->m_p_parent != 0)
+ other.m_size = other.m_p_head->m_p_parent->m_subtree_size;
m_size -= other.m_size;
initialize_min_max();
PB_DS_ASSERT_VALID((*this))
--
2.27.0