]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Force-inline shared_ptr::operator bool() for C++20 [PR108636]
authorJonathan Wakely <jwakely@redhat.com>
Thu, 1 Feb 2024 18:37:34 +0000 (18:37 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 2 Feb 2024 10:35:06 +0000 (10:35 +0000)
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

index c22b397a194675ef59ce424b6b2667724812496e..23c3b17d46f94493f16814c5c35591352804087c 100644 (file)
@@ -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; }