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

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