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-8908] libstdc++: Set active union member in constexpr std::string [PR103295] Date: Mon, 14 Nov 2022 18:34:43 +0000 (GMT) [thread overview] Message-ID: <20221114183443.DD1BB382E536@sourceware.org> (raw) https://gcc.gnu.org/g:a088d93c210f9b662d706e2fcf63a59d05fe27c1 commit r12-8908-ga088d93c210f9b662d706e2fcf63a59d05fe27c1 Author: Nathaniel Shead <nathanieloshead@gmail.com> Date: Fri Nov 11 22:23:31 2022 +1100 libstdc++: Set active union member in constexpr std::string [PR103295] Clang still complains about using std::string in constexpr contexts due to the changes made in commit 98a0d72a. This patch ensures that we set the active member of the union as according to [class.union.general] p6. libstdc++-v3/ChangeLog: PR libstdc++/103295 * include/bits/basic_string.h (_M_use_local_data): Set active member to _M_local_buf. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> (cherry picked from commit 52672be7d328df50f9a05ce3ab44ebcae50fee1b) Diff: --- libstdc++-v3/include/bits/basic_string.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h index 9777deaf2e9..f1a0e6984a1 100644 --- a/libstdc++-v3/include/bits/basic_string.h +++ b/libstdc++-v3/include/bits/basic_string.h @@ -352,8 +352,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 { #if __cpp_lib_is_constant_evaluated if (std::is_constant_evaluated()) - for (_CharT& __c : _M_local_buf) - __c = _CharT(); + for (size_type __i = 0; __i <= _S_local_capacity; ++__i) + _M_local_buf[__i] = _CharT(); #endif return _M_local_data(); }
reply other threads:[~2022-11-14 18:34 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=20221114183443.DD1BB382E536@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).