From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id D10BD3857810 for ; Fri, 1 Oct 2021 19:43:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D10BD3857810 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-8-fK2Fj8NiO--EZcqmdcd33A-1; Fri, 01 Oct 2021 15:43:07 -0400 X-MC-Unique: fK2Fj8NiO--EZcqmdcd33A-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8A24E100CCC6; Fri, 1 Oct 2021 19:43:06 +0000 (UTC) Received: from localhost (unknown [10.33.36.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 38AE55C1B4; Fri, 1 Oct 2021 19:43:06 +0000 (UTC) Date: Fri, 1 Oct 2021 20:43:00 +0100 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Simplify __throw_out_of_range_fmt for freestanding Message-ID: MIME-Version: 1.0 X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="Azp+Ms6RQjzX4Zvm" Content-Disposition: inline X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=unavailable autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Oct 2021 19:43:24 -0000 --Azp+Ms6RQjzX4Zvm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline There is no point expanding the format string if we're just going to abort instead of throw an exception. And for freestanding or non-verbose builds we shouldn't do it either, to reduce the binary size. Signed-off-by: Jonathan Wakely libstdc++-v3/ChangeLog: * src/c++11/functexcept.cc (__throw_out_of_range_fmt): Do not expand the format string for freestanding, or non-vebose, or if we're just going to abort anyway. * src/c++11/snprintf_lite.cc: Remove unused header and declaration. Tested powerpc64le-linux. Committed to trunk. --Azp+Ms6RQjzX4Zvm Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="patch.txt" commit 44967af830a8d887f0d7b6848d40e1c0870b6b0e Author: Jonathan Wakely Date: Thu May 20 18:13:00 2021 libstdc++: Simplify __throw_out_of_range_fmt for freestanding There is no point expanding the format string if we're just going to abort instead of throw an exception. And for freestanding or non-verbose builds we shouldn't do it either, to reduce the binary size. Signed-off-by: Jonathan Wakely libstdc++-v3/ChangeLog: * src/c++11/functexcept.cc (__throw_out_of_range_fmt): Do not expand the format string for freestanding, or non-vebose, or if we're just going to abort anyway. * src/c++11/snprintf_lite.cc: Remove unused header and declaration. diff --git a/libstdc++-v3/src/c++11/functexcept.cc b/libstdc++-v3/src/c++11/functexcept.cc index 6f0071391c7..d1570b69f15 100644 --- a/libstdc++-v3/src/c++11/functexcept.cc +++ b/libstdc++-v3/src/c++11/functexcept.cc @@ -88,6 +88,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION void __throw_out_of_range_fmt(const char* __fmt, ...) { +#if _GLIBCXX_HOSTED && _GLIBCXX_VERBOSE && __cpp_exceptions const size_t __len = __builtin_strlen(__fmt); // We expect at most 2 numbers, and 1 short string. The additional // 512 bytes should provide more than enough space for expansion. @@ -96,9 +97,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION va_list __ap; va_start(__ap, __fmt); - __gnu_cxx::__snprintf_lite(__s, __alloca_size, __fmt, __ap); - _GLIBCXX_THROW_OR_ABORT(out_of_range(_(__s))); + __gnu_cxx::__snprintf_lite(__s, __alloca_size, _(__fmt), __ap); + throw out_of_range(__s); va_end(__ap); // Not reached. +#else + __throw_out_of_range(__fmt); +#endif } void diff --git a/libstdc++-v3/src/c++11/snprintf_lite.cc b/libstdc++-v3/src/c++11/snprintf_lite.cc index dcf8421cac2..ffeb7bf64c0 100644 --- a/libstdc++-v3/src/c++11/snprintf_lite.cc +++ b/libstdc++-v3/src/c++11/snprintf_lite.cc @@ -24,17 +24,8 @@ // . #include +#include #include -#include - -namespace std { -_GLIBCXX_BEGIN_NAMESPACE_VERSION - template - int - __int_to_char(_CharT* __bufend, _ValueT __v, const _CharT* __lit, - ios_base::fmtflags __flags, bool __dec); -_GLIBCXX_END_NAMESPACE_VERSION -} namespace __gnu_cxx { --Azp+Ms6RQjzX4Zvm--