From patchwork Tue Mar 28 23:19:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 67058 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D1F9B38582AB for ; Tue, 28 Mar 2023 23:20:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D1F9B38582AB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1680045611; bh=7VWxsGH9Cs/zvk47wkIprvkoZ73snYCDlc05p52959Y=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=uqpUpDHFHsfesC2bgfCD5u1+UKyQDyKL3LIcZVZVUlpCtVuuH5vuRgoAMthTl4ycl 0OzzpLTFBkF7/9yhHkIkRcgUN9hCOXIwMk68PqcxVabxvNmcld3po2oWk6CB+hSGl8 Rfuf9IcXq9SQ9TNv6nEGS5/6WXmyZkex44prmuOM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 292D43858425 for ; Tue, 28 Mar 2023 23:19:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 292D43858425 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-187-zefNcpM1PemBsUcVn6uENA-1; Tue, 28 Mar 2023 19:19:04 -0400 X-MC-Unique: zefNcpM1PemBsUcVn6uENA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1EF741C05EC7; Tue, 28 Mar 2023 23:19:04 +0000 (UTC) Received: from localhost (unknown [10.33.36.149]) by smtp.corp.redhat.com (Postfix) with ESMTP id DA5BD4020C82; Tue, 28 Mar 2023 23:19:03 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Do not use facets cached in ios for ATL128 build [PR103387] Date: Wed, 29 Mar 2023 00:19:03 +0100 Message-Id: <20230328231903.1214366-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Tested powerpc64le-linux. Pushed to trunk. -- >8 -- 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. --- libstdc++-v3/include/bits/istream.tcc | 15 +++++++++++++++ libstdc++-v3/include/bits/ostream.tcc | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/libstdc++-v3/include/bits/istream.tcc b/libstdc++-v3/include/bits/istream.tcc index 733a8359902..334a91755aa 100644 --- a/libstdc++-v3/include/bits/istream.tcc +++ b/libstdc++-v3/include/bits/istream.tcc @@ -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 diff --git a/libstdc++-v3/include/bits/ostream.tcc b/libstdc++-v3/include/bits/ostream.tcc index e20012d2dc6..bb8584276f5 100644 --- a/libstdc++-v3/include/bits/ostream.tcc +++ b/libstdc++-v3/include/bits/ostream.tcc @@ -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; }