public inbox for libstdc++-cvs@sourceware.org help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r12-4073] libstdc++: Simplify __throw_out_of_range_fmt for freestanding Date: Fri, 1 Oct 2021 19:39:20 +0000 (GMT) [thread overview] Message-ID: <20211001193920.958D83857C5E@sourceware.org> (raw) https://gcc.gnu.org/g:44967af830a8d887f0d7b6848d40e1c0870b6b0e commit r12-4073-g44967af830a8d887f0d7b6848d40e1c0870b6b0e Author: Jonathan Wakely <jwakely@redhat.com> Date: Thu May 20 18:13:00 2021 +0100 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 <jwakely@redhat.com> 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: --- libstdc++-v3/src/c++11/functexcept.cc | 8 ++++++-- libstdc++-v3/src/c++11/snprintf_lite.cc | 11 +---------- 2 files changed, 7 insertions(+), 12 deletions(-) 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 @@ // <http://www.gnu.org/licenses/>. #include <stdarg.h> +#include <stddef.h> #include <bits/functexcept.h> -#include <bits/locale_facets.h> - -namespace std { -_GLIBCXX_BEGIN_NAMESPACE_VERSION - template<typename _CharT, typename _ValueT> - int - __int_to_char(_CharT* __bufend, _ValueT __v, const _CharT* __lit, - ios_base::fmtflags __flags, bool __dec); -_GLIBCXX_END_NAMESPACE_VERSION -} namespace __gnu_cxx {
reply other threads:[~2021-10-01 19:39 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211001193920.958D83857C5E@sourceware.org \ --to=redi@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ --cc=libstdc++-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).