Blame SOURCES/0006-Don-t-assume-has_facet-codecvt_c16-when-run-against-.patch

759f0e
From 59388ee3dac5c737086ed1f83f552a44481a2213 Mon Sep 17 00:00:00 2001
759f0e
From: David Malcolm <dmalcolm@redhat.com>
759f0e
Date: Tue, 31 Aug 2021 16:08:57 -0400
759f0e
Subject: [PATCH 06/17] Don't assume has_facet<codecvt_c16> when run against
759f0e
 system libstdc++
759f0e
759f0e
Upstream commit 2019-02-19:
759f0e
  P0482R5 char8_t: Standard library support
759f0e
    https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=c124af936b6b225eb548ccdd7f01400511d784dc
759f0e
added new locale facets for char8_t.
759f0e
759f0e
has_facet<codecvt_c16> returns false, as it is using the std::locale the system libstdc++:
759f0e
759f0e
$ eu-readelf -s char16_t-char8_t.exe |c++filt |grep UNDEF|grep locale
759f0e
    3: 0000000000000000      0 FUNC    GLOBAL DEFAULT    UNDEF std::locale::classic()@GLIBCXX_3.4 (2)
759f0e
    8: 0000000000000000      0 FUNC    GLOBAL DEFAULT    UNDEF std::locale::locale(std::locale const&)@GLIBCXX_3.4 (2)
759f0e
   13: 0000000000000000      0 FUNC    GLOBAL DEFAULT    UNDEF std::locale::id::_M_id() const@GLIBCXX_3.4 (2)
759f0e
   22: 0000000000000000      0 FUNC    GLOBAL DEFAULT    UNDEF std::locale::~locale()@GLIBCXX_3.4 (2)
759f0e
   64: 0000000000000000      0 FUNC    GLOBAL DEFAULT    UNDEF std::locale::classic()@@GLIBCXX_3.4
759f0e
   76: 0000000000000000      0 FUNC    GLOBAL DEFAULT    UNDEF std::locale::locale(std::locale const&)@@GLIBCXX_3.4
759f0e
   89: 0000000000000000      0 FUNC    GLOBAL DEFAULT    UNDEF std::locale::id::_M_id() const@@GLIBCXX_3.4
759f0e
  108: 0000000000000000      0 FUNC    GLOBAL DEFAULT    UNDEF std::locale::~locale()@@GLIBCXX_3.4
759f0e
759f0e
Hence this patch tweaks tests so that they bail out if run against an older std::locale.
759f0e
---
759f0e
 libstdc++-v3/testsuite/22_locale/codecvt/char16_t-char8_t.cc | 3 ++-
759f0e
 libstdc++-v3/testsuite/22_locale/codecvt/char16_t.cc         | 3 ++-
759f0e
 libstdc++-v3/testsuite/22_locale/codecvt/char32_t-char8_t.cc | 3 ++-
759f0e
 libstdc++-v3/testsuite/22_locale/codecvt/char32_t.cc         | 3 ++-
759f0e
 libstdc++-v3/testsuite/22_locale/codecvt/utf8-char8_t.cc     | 2 ++
759f0e
 libstdc++-v3/testsuite/22_locale/codecvt/utf8.cc             | 2 ++
759f0e
 6 files changed, 12 insertions(+), 4 deletions(-)
759f0e
759f0e
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/char16_t-char8_t.cc b/libstdc++-v3/testsuite/22_locale/codecvt/char16_t-char8_t.cc
759f0e
index 71a23bef4..d4aa519a2 100644
759f0e
--- a/libstdc++-v3/testsuite/22_locale/codecvt/char16_t-char8_t.cc
759f0e
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/char16_t-char8_t.cc
759f0e
@@ -31,7 +31,8 @@ test01()
759f0e
   using namespace std;
759f0e
   typedef codecvt<char16_t, char8_t, mbstate_t> codecvt_c16;
759f0e
   locale loc_c = locale::classic();
759f0e
-  VERIFY(has_facet<codecvt_c16>(loc_c));
759f0e
+  if (!has_facet<codecvt_c16>(loc_c))
759f0e
+    return;
759f0e
   const codecvt_c16* const cvt = &use_facet<codecvt_c16>(loc_c);
759f0e
 
759f0e
   VERIFY(!cvt->always_noconv());
759f0e
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/char16_t.cc b/libstdc++-v3/testsuite/22_locale/codecvt/char16_t.cc
759f0e
index 7b5ce126d..05c77b2b1 100644
759f0e
--- a/libstdc++-v3/testsuite/22_locale/codecvt/char16_t.cc
759f0e
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/char16_t.cc
759f0e
@@ -29,7 +29,8 @@ test01()
759f0e
   using namespace std;
759f0e
   typedef codecvt<char16_t, char, mbstate_t> codecvt_c16;
759f0e
   locale loc_c = locale::classic();
759f0e
-  VERIFY(has_facet<codecvt_c16>(loc_c));
759f0e
+  if (!has_facet<codecvt_c16>(loc_c))
759f0e
+    return;
759f0e
   const codecvt_c16* const cvt = &use_facet<codecvt_c16>(loc_c);
759f0e
 
759f0e
   VERIFY(!cvt->always_noconv());
759f0e
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/char32_t-char8_t.cc b/libstdc++-v3/testsuite/22_locale/codecvt/char32_t-char8_t.cc
759f0e
index f30ae22e9..281969e9b 100644
759f0e
--- a/libstdc++-v3/testsuite/22_locale/codecvt/char32_t-char8_t.cc
759f0e
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/char32_t-char8_t.cc
759f0e
@@ -33,7 +33,8 @@ test01()
759f0e
   using namespace std;
759f0e
   typedef codecvt<char32_t, char8_t, mbstate_t> codecvt_c32;
759f0e
   locale loc_c = locale::classic();
759f0e
-  VERIFY(has_facet<codecvt_c32>(loc_c));
759f0e
+  if (!has_facet<codecvt_c32>(loc_c))
759f0e
+    return;
759f0e
   const codecvt_c32* const cvt = &use_facet<codecvt_c32>(loc_c);
759f0e
 
759f0e
   VERIFY(!cvt->always_noconv());
759f0e
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/char32_t.cc b/libstdc++-v3/testsuite/22_locale/codecvt/char32_t.cc
759f0e
index 558ba9145..82980b702 100644
759f0e
--- a/libstdc++-v3/testsuite/22_locale/codecvt/char32_t.cc
759f0e
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/char32_t.cc
759f0e
@@ -31,7 +31,8 @@ test01()
759f0e
   using namespace std;
759f0e
   typedef codecvt<char32_t, char, mbstate_t> codecvt_c32;
759f0e
   locale loc_c = locale::classic();
759f0e
-  VERIFY(has_facet<codecvt_c32>(loc_c));
759f0e
+  if (!has_facet<codecvt_c32>(loc_c))
759f0e
+    return;
759f0e
   const codecvt_c32* const cvt = &use_facet<codecvt_c32>(loc_c);
759f0e
 
759f0e
   VERIFY(!cvt->always_noconv());
759f0e
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/utf8-char8_t.cc b/libstdc++-v3/testsuite/22_locale/codecvt/utf8-char8_t.cc
759f0e
index 5eab05ba2..d6f663ce6 100644
759f0e
--- a/libstdc++-v3/testsuite/22_locale/codecvt/utf8-char8_t.cc
759f0e
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/utf8-char8_t.cc
759f0e
@@ -34,6 +34,8 @@ void test(const C* from)
759f0e
   std::mbstate_t state{};
759f0e
   char8_t buf[16] = { };
759f0e
   using test_type = std::codecvt<C, char8_t, std::mbstate_t>;
759f0e
+  if (!std::has_facet<test_type>(std::locale::classic()))
759f0e
+    return;
759f0e
   const test_type& cvt = std::use_facet<test_type>(std::locale::classic());
759f0e
   auto from_end = from + len;
759f0e
   auto from_next = from;
759f0e
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/utf8.cc b/libstdc++-v3/testsuite/22_locale/codecvt/utf8.cc
759f0e
index b1b3cff31..167bc0ca3 100644
759f0e
--- a/libstdc++-v3/testsuite/22_locale/codecvt/utf8.cc
759f0e
+++ b/libstdc++-v3/testsuite/22_locale/codecvt/utf8.cc
759f0e
@@ -32,6 +32,8 @@ void test(const C* from)
759f0e
   std::mbstate_t state{};
759f0e
   char buf[16] = { };
759f0e
   using test_type = std::codecvt<C, char, std::mbstate_t>;
759f0e
+  if (!std::has_facet<test_type>(std::locale::classic()))
759f0e
+    return;
759f0e
   const test_type& cvt = std::use_facet<test_type>(std::locale::classic());
759f0e
   auto from_end = from + len;
759f0e
   auto from_next = from;
759f0e
-- 
759f0e
2.31.1
759f0e