]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Do not use facets cached in ios for ALT128 build [PR103387]
authorJonathan Wakely <jwakely@redhat.com>
Tue, 28 Mar 2023 20:07:21 +0000 (21:07 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 20 Apr 2023 11:27:01 +0000 (12:27 +0100)
For the powerpc64le build with two different long double
representations, we cannot use the ios_base::_M_num_put and
ios_base::_M_num_get pointers, because they might have been initialized
in a translation unit using the other long double type. With the changes
to add __try_use_facet to GCC 13 the cache isn't really needed now, we
can just access the right facet in the locale directly, without needing
RTTI checks.

libstdc++-v3/ChangeLog:

PR libstdc++/103387
* include/bits/istream.tcc (istream::_M_extract(ValueT&)): Use
std::use_facet instead of cached _M_num_get facet.
(istream::operator>>(short&)): Likewise.
(istream::operator>>(int&)): Likewise.
* include/bits/ostream.tcc (ostream::_M_insert(ValueT)): Use
std::use_facet instead of cached _M_num_put facet.

(cherry picked from commit ec12639c82e944d37200a744156e183ea19add00)

libstdc++-v3/include/bits/istream.tcc
libstdc++-v3/include/bits/ostream.tcc

index a1a7d89335e08985e178752496a67314ccd9b3db..dc4be3461d4bc3ad969404dd5102486b5e9791d7 100644 (file)
@@ -102,7 +102,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
            ios_base::iostate __err = ios_base::goodbit;
            __try
              {
+#ifndef _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT
                const __num_get_type& __ng = __check_facet(this->_M_num_get);
+#else
+               const __num_get_type& __ng
+                 = use_facet<__num_get_type>(this->_M_ios_locale);
+#endif
                __ng.get(*this, 0, *this, __err, __v);
              }
            __catch(__cxxabiv1::__forced_unwind&)
@@ -132,7 +137,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
          __try
            {
              long __l;
+#ifndef _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT
              const __num_get_type& __ng = __check_facet(this->_M_num_get);
+#else
+             const __num_get_type& __ng
+               = use_facet<__num_get_type>(this->_M_ios_locale);
+#endif
              __ng.get(*this, 0, *this, __err, __l);
 
              // _GLIBCXX_RESOLVE_LIB_DEFECTS
@@ -177,7 +187,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
          __try
            {
              long __l;
+#ifndef _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT
              const __num_get_type& __ng = __check_facet(this->_M_num_get);
+#else
+             const __num_get_type& __ng
+               = use_facet<__num_get_type>(this->_M_ios_locale);
+#endif
              __ng.get(*this, 0, *this, __err, __l);
 
              // _GLIBCXX_RESOLVE_LIB_DEFECTS
index ba337c81aa85c2e0f9c550e02929496364f040f1..05e684275f5b0cc6cfd699500b0387a075971f80 100644 (file)
@@ -69,7 +69,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
            ios_base::iostate __err = ios_base::goodbit;
            __try
              {
+#ifndef _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT
                const __num_put_type& __np = __check_facet(this->_M_num_put);
+#else
+               const __num_put_type& __np
+                 = use_facet<__num_put_type>(this->_M_ios_locale);
+#endif
                if (__np.put(*this, *this, this->fill(), __v).failed())
                  __err |= ios_base::badbit;
              }