From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [committed,gcc-12] libstdc++: Force-inline shared_ptr::operator bool() for C++20 [PR108636]
Date: Fri, 2 Feb 2024 10:39:25 +0000 [thread overview]
Message-ID: <20240202103952.2243921-1-jwakely@redhat.com> (raw)
Tested x86_64-linux. Pushed to releases/gcc-12 branch.
-- >8 --
This avoids a linker error with -fkeep-inline-functions when including
<filesystem>. We can't backport the fix from trunk because it adds an
export to the shared library. By marking the "missing" symbol
always_inline for C++20 mode we don't need a definition in the library.
libstdc++-v3/ChangeLog:
PR libstdc++/108636
* include/bits/shared_ptr_base.h (__shared_ptr::operator bool):
Add always_inline attribute for C++20 and later.
---
libstdc++-v3/include/bits/shared_ptr_base.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h
index c22b397a194..23c3b17d46f 100644
--- a/libstdc++-v3/include/bits/shared_ptr_base.h
+++ b/libstdc++-v3/include/bits/shared_ptr_base.h
@@ -1666,6 +1666,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ return _M_ptr; }
/// Return true if the stored pointer is not null.
+#if __cplusplus >= 202002L
+ [[__gnu__::__always_inline__]]
+#endif
explicit operator bool() const noexcept
{ return _M_ptr != nullptr; }
--
2.43.0
reply other threads:[~2024-02-02 10: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=20240202103952.2243921-1-jwakely@redhat.com \
--to=jwakely@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@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: link
Be 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).