aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2024-06-11 15:52:30 +0100
committerJonathan Wakely <jwakely@redhat.com>2024-06-14 15:24:14 +0100
commit6af8d8e618ed27dae3432c96484de4360bd893ab (patch)
treed20a08a70c304bee0caef69217e9404c72524200
parent161efd677458f20d13ee1018a4d5e3964febd508 (diff)
downloadgcc-6af8d8e618ed27dae3432c96484de4360bd893ab.zip
gcc-6af8d8e618ed27dae3432c96484de4360bd893ab.tar.gz
gcc-6af8d8e618ed27dae3432c96484de4360bd893ab.tar.bz2
libstdc++: Make std::type_info::operator== always_inline for C++23 [PR110572]
Commit r12-6266-g3633cc54284450 implemented P1328 for C++23, making std::type_info::operator== usable in constant expressions. For targets such as mingw-w64 where that function was not previously inline, making it constexpr required making it inline for C++23 and later. For statically linked programs this can result in multiple definition errors, because there's a non-inline definition in libstdc++.a as well. For those targets make it always_inline for C++23, so that there is no symbol generated for the inline definition, and the non-inline definition in libstdc++.a will be the only definition. libstdc++-v3/ChangeLog: PR libstdc++/110572 * libsupc++/typeinfo (type_info::operator==): Add always_inline attribute for targets where the ABI requries equality to be non-inline. * testsuite/18_support/type_info/110572.cc: New test.
-rw-r--r--libstdc++-v3/libsupc++/typeinfo3
-rw-r--r--libstdc++-v3/testsuite/18_support/type_info/110572.cc11
2 files changed, 14 insertions, 0 deletions
diff --git a/libstdc++-v3/libsupc++/typeinfo b/libstdc++-v3/libsupc++/typeinfo
index fcc3077..35e72bb 100644
--- a/libstdc++-v3/libsupc++/typeinfo
+++ b/libstdc++-v3/libsupc++/typeinfo
@@ -188,6 +188,9 @@ namespace std
#endif
#if __GXX_TYPEINFO_EQUALITY_INLINE || __cplusplus > 202002L
+# if ! __GXX_TYPEINFO_EQUALITY_INLINE
+ [[__gnu__::__always_inline__]]
+# endif
_GLIBCXX23_CONSTEXPR inline bool
type_info::operator==(const type_info& __arg) const _GLIBCXX_NOEXCEPT
{
diff --git a/libstdc++-v3/testsuite/18_support/type_info/110572.cc b/libstdc++-v3/testsuite/18_support/type_info/110572.cc
new file mode 100644
index 0000000..6408187
--- /dev/null
+++ b/libstdc++-v3/testsuite/18_support/type_info/110572.cc
@@ -0,0 +1,11 @@
+// { dg-options "-static-libstdc++" }
+// { dg-require-static-libstdcxx }
+// { dg-require-cpp-feature-test __cpp_rtti }
+// { dg-do link }
+
+#include <typeinfo>
+
+int main()
+{
+ return typeid(0) == typeid(0u);
+}