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 r9-9590] libstdc++: Simplify constexpr checks in std::char_traits [PR 91488] Date: Fri, 18 Jun 2021 14:43:29 +0000 (GMT) [thread overview] Message-ID: <20210618144329.A18773AA9831@sourceware.org> (raw) https://gcc.gnu.org/g:cc44169fc7bc7552eb85f143f4fee9c8bcdd5e49 commit r9-9590-gcc44169fc7bc7552eb85f143f4fee9c8bcdd5e49 Author: Jonathan Wakely <jwakely@redhat.com> Date: Thu Jun 17 14:11:22 2021 +0100 libstdc++: Simplify constexpr checks in std::char_traits [PR 91488] This removes the 'static' keyword from the helper functions added by r8-1294 to detect whether the char_traits member functions can be evaluated at compile time. This prevents the "inlining failed" error reported in the PR. The new testcase from the PR is added to the libitm testsuite, because that's where we can be sure it's OK to use the -fgnu-tm option. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> PR libstdc++/91488 libstdc++-v3/ChangeLog: * include/bits/char_traits.h (__constant_string_p) (__constant_array_p): Give external linkage. libitm/ChangeLog: * testsuite/libitm.c++/libstdc++-pr91488.C: New test. (cherry picked from commit b376b1ef38971b84975ad1540bf5d2ae0b924e76) Diff: --- libitm/testsuite/libitm.c++/libstdc++-pr91488.C | 9 +++++++++ libstdc++-v3/include/bits/char_traits.h | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/libitm/testsuite/libitm.c++/libstdc++-pr91488.C b/libitm/testsuite/libitm.c++/libstdc++-pr91488.C new file mode 100644 index 00000000000..e9e82bd1ce2 --- /dev/null +++ b/libitm/testsuite/libitm.c++/libstdc++-pr91488.C @@ -0,0 +1,9 @@ +// PR libstdc++/91488 "inlining failed in call to always_inline" +// { dg-do run } +// { dg-additional-options "-O1" } + +#include <string> + +int main() { + return std::char_traits<char>::length(""); +} diff --git a/libstdc++-v3/include/bits/char_traits.h b/libstdc++-v3/include/bits/char_traits.h index 50bd25eb2df..4c7b84e357f 100644 --- a/libstdc++-v3/include/bits/char_traits.h +++ b/libstdc++-v3/include/bits/char_traits.h @@ -227,7 +227,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * Assumes that _CharT is a built-in character type. */ template<typename _CharT> - static _GLIBCXX_ALWAYS_INLINE constexpr bool + _GLIBCXX_ALWAYS_INLINE constexpr bool __constant_string_p(const _CharT* __s) { #ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED @@ -250,7 +250,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * Assumes that _CharT is a built-in character type. */ template<typename _CharT> - static _GLIBCXX_ALWAYS_INLINE constexpr bool + _GLIBCXX_ALWAYS_INLINE constexpr bool __constant_char_array_p(const _CharT* __a, size_t __n) { #ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED
reply other threads:[~2021-06-18 14:43 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=20210618144329.A18773AA9831@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).