Blame SOURCES/0016-Conditionalize-test-for-hashtable-bucket-sizes-on-__.patch

44ce1d
From db8f53df0be1daeda3159c1413549ff40696c710 Mon Sep 17 00:00:00 2001
44ce1d
From: David Malcolm <dmalcolm@redhat.com>
44ce1d
Date: Thu, 2 Sep 2021 17:02:33 -0400
44ce1d
Subject: [PATCH 16/17] Conditionalize test for hashtable bucket sizes on
44ce1d
 __LIBSTDCXX_SO_VERSION >= 11
44ce1d
44ce1d
These tests were added upstream 2020-01-20 as part of:
44ce1d
  libstdc++: Do not over-size hashtable buckets on range insertion
44ce1d
    https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=6dcf042368012e2d7ce1626ee5d378bf3ad0ccfc
44ce1d
44ce1d
but fail when run in DTS against a system libstdc++.so from an older GCC.
44ce1d
44ce1d
In particular, _M_insert_unique_node from the header is using the older
44ce1d
implementation of
44ce1d
  std::__detail::_Prime_rehash_policy::_M_need_rehash
44ce1d
from the dynamic library.
44ce1d
44ce1d
   23: 0000000000000000      0 FUNC    GLOBAL DEFAULT    UNDEF std::__detail::_Prime_rehash_policy::_M_need_rehash(unsigned long, unsigned long, unsigned long) const@GLIBCXX_3.4.18 (5)
44ce1d
  412: 0000000000000000      0 FUNC    GLOBAL DEFAULT    UNDEF std::__detail::_Prime_rehash_policy::_M_need_rehash(unsigned long, unsigned long, unsigned long) const@@GLIBCXX_3.4.18
44ce1d
---
44ce1d
 .../23_containers/unordered_set/cons/bucket_hint.cc    | 10 ++++++++++
44ce1d
 .../23_containers/unordered_set/modifiers/insert.cc    |  9 +++++++++
44ce1d
 2 files changed, 19 insertions(+)
44ce1d
44ce1d
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/cons/bucket_hint.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/cons/bucket_hint.cc
44ce1d
index a3b014a3a..af231e54e 100644
44ce1d
--- a/libstdc++-v3/testsuite/23_containers/unordered_set/cons/bucket_hint.cc
44ce1d
+++ b/libstdc++-v3/testsuite/23_containers/unordered_set/cons/bucket_hint.cc
44ce1d
@@ -29,7 +29,11 @@ void test01()
44ce1d
   a.reserve(2);
44ce1d
 
44ce1d
   std::unordered_set<int> b({ 0, 1, 0, 1, 0, 1, 0, 1 }, a.bucket_count());
44ce1d
+
44ce1d
+  // Fixed upstream in GCC 11
44ce1d
+#if __LIBSTDCXX_SO_VERSION >= 11
44ce1d
   VERIFY( b.bucket_count() == a.bucket_count() );
44ce1d
+#endif
44ce1d
 }
44ce1d
 
44ce1d
 void test02()
44ce1d
@@ -40,7 +44,10 @@ void test02()
44ce1d
   std::vector<int> v { 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 };
44ce1d
 
44ce1d
   std::unordered_set<int> b(v.begin(), v.end(), a.bucket_count());
44ce1d
+  // Fixed upstream in GCC 11
44ce1d
+#if __LIBSTDCXX_SO_VERSION >= 11
44ce1d
   VERIFY( b.bucket_count() == a.bucket_count() );
44ce1d
+#endif
44ce1d
 }
44ce1d
 
44ce1d
 void test03()
44ce1d
@@ -51,7 +58,10 @@ void test03()
44ce1d
   std::forward_list<int> fl { 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 };
44ce1d
 
44ce1d
   std::unordered_set<int> b(fl.begin(), fl.end(), a.bucket_count());
44ce1d
+  // Fixed upstream in GCC 11
44ce1d
+#if __LIBSTDCXX_SO_VERSION >= 11
44ce1d
   VERIFY( b.bucket_count() == a.bucket_count() );
44ce1d
+#endif
44ce1d
 }
44ce1d
 
44ce1d
 int main()
44ce1d
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/modifiers/insert.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/modifiers/insert.cc
44ce1d
index 015c2f872..aae8298ae 100644
44ce1d
--- a/libstdc++-v3/testsuite/23_containers/unordered_set/modifiers/insert.cc
44ce1d
+++ b/libstdc++-v3/testsuite/23_containers/unordered_set/modifiers/insert.cc
44ce1d
@@ -30,7 +30,10 @@ void test01()
44ce1d
 
44ce1d
   auto bkt_count = a.bucket_count();
44ce1d
   a.insert({ 0, 1, 0, 1, 0, 1, 0, 1 });
44ce1d
+  // Fixed upstream in GCC 11
44ce1d
+#if __LIBSTDCXX_SO_VERSION >= 11
44ce1d
   VERIFY( a.bucket_count() == bkt_count );
44ce1d
+#endif
44ce1d
 }
44ce1d
 
44ce1d
 void test02()
44ce1d
@@ -42,7 +45,10 @@ void test02()
44ce1d
 
44ce1d
   auto bkt_count = a.bucket_count();
44ce1d
   a.insert(v.begin(), v.end());
44ce1d
+  // Fixed upstream in GCC 11
44ce1d
+#if __LIBSTDCXX_SO_VERSION >= 11
44ce1d
   VERIFY( a.bucket_count() == bkt_count );
44ce1d
+#endif
44ce1d
 }
44ce1d
 
44ce1d
 void test03()
44ce1d
@@ -54,7 +60,10 @@ void test03()
44ce1d
 
44ce1d
   auto bkt_count = a.bucket_count();
44ce1d
   a.insert(fl.begin(), fl.end());
44ce1d
+  // Fixed upstream in GCC 11
44ce1d
+#if __LIBSTDCXX_SO_VERSION >= 11
44ce1d
   VERIFY( a.bucket_count() == bkt_count );
44ce1d
+#endif
44ce1d
 }
44ce1d
 
44ce1d
 int main()
44ce1d
-- 
44ce1d
2.31.1
44ce1d