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 r11-6146] libstdc++: Only use __builtin_sprintf if supported [PR 96083] Date: Wed, 16 Dec 2020 14:33:46 +0000 (GMT) [thread overview] Message-ID: <20201216143346.760253854810@sourceware.org> (raw) https://gcc.gnu.org/g:96d9670e88333d8896a5d2f2bb0403c1e2ad19ab commit r11-6146-g96d9670e88333d8896a5d2f2bb0403c1e2ad19ab Author: Jonathan Wakely <jwakely@redhat.com> Date: Wed Dec 16 13:50:34 2020 +0000 libstdc++: Only use __builtin_sprintf if supported [PR 96083] Clang doesn't support __builtin_sprintf, so use std::sprintf instead. libstdc++-v3/ChangeLog: PR libstdc++/96083 * include/ext/throw_allocator.h: Use __has_builtin to check for __builtin_sprintf support, and use std::sprtinf if necessary. Diff: --- libstdc++-v3/include/ext/throw_allocator.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/libstdc++-v3/include/ext/throw_allocator.h b/libstdc++-v3/include/ext/throw_allocator.h index 0ab174f19a5..2364827a632 100644 --- a/libstdc++-v3/include/ext/throw_allocator.h +++ b/libstdc++-v3/include/ext/throw_allocator.h @@ -64,6 +64,10 @@ #endif #include <ext/alloc_traits.h> +#if !__has_builtin(__builtin_sprintf) +# include <cstdio> +#endif + namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION @@ -310,6 +314,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static void log_to_string(std::string& s, const_reference ref) { +#if ! __has_builtin(__builtin_sprintf) + __typeof__(&std::sprintf) __builtin_sprintf = &std::sprintf; +#endif + char buf[40]; const char tab('\t'); s += "label: "; @@ -332,6 +340,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static void log_to_string(std::string& s, const std::pair<const void*, size_t>& ref) { +#if ! __has_builtin(__builtin_sprintf) + auto __builtin_sprintf = &std::sprintf; +#endif + char buf[40]; const char tab('\t'); s += "label: "; @@ -566,6 +578,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static gen_t generator(engine(), distribution); #endif +#if ! __has_builtin(__builtin_sprintf) + __typeof__(&std::sprintf) __builtin_sprintf = &std::sprintf; +#endif + double random = generator(); if (random < distribution.min() || random > distribution.max()) {
reply other threads:[~2020-12-16 14:33 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=20201216143346.760253854810@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).