From 3633cc54284450433b81f0340483e15df1a49a3c Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Wed, 5 Jan 2022 14:25:37 +0000 Subject: libstdc++: Implement P1328 "Making std::type_info::operator== constexpr" This feature is present in the C++23 draft. With Jakub's recent front-end changes we can implement constexpr equality by comparing the addresses of std::type_info objects. We do not need string comparisons, because for constant evaluation cases we know we aren't dealing with std::type_info objects defined in other translation units. The ARM EABI requires that the type_info::operator== function can be defined out-of-line (and suggests that should be the default), but to be a constexpr function it must be defined inline (at least for C++23 mode). To meet these conflicting requirements we make the inline version of operator== call a new __equal function when called at runtime. That is an alias for the non-inline definition of operator== defined in libsupc++. libstdc++-v3/ChangeLog: * config/abi/pre/gnu.ver (GLIBCXX_3.4.30): Export new symbol for ARM EABI. * include/bits/c++config (_GLIBCXX23_CONSTEXPR): Define. * include/std/version (__cpp_lib_constexpr_typeinfo): Define. * libsupc++/tinfo.cc: Add #error to ensure non-inline definition is emitted. (type_info::__equal): Define alias symbol. * libsupc++/typeinfo (type_info::before): Combine different implementations into one. (type_info::operator==): Likewise. Use address equality for constant evaluation. Call __equal for targets that require the definition to be non-inline. * testsuite/18_support/type_info/constexpr.cc: New test. --- libstdc++-v3/config/abi/pre/gnu.ver | 3 +++ 1 file changed, 3 insertions(+) (limited to 'libstdc++-v3/config/abi/pre/gnu.ver') diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver index c2f09a9..afd242b 100644 --- a/libstdc++-v3/config/abi/pre/gnu.ver +++ b/libstdc++-v3/config/abi/pre/gnu.ver @@ -2424,6 +2424,9 @@ GLIBCXX_3.4.30 { # std::__timepunct::_M_am_pm_format(const char**) _ZNKSt11__timepunctI[cw]E15_M_am_pm_formatEPPK[cw]; + # Only defined #if ! __GXX_TYPEINFO_EQUALITY_INLINE + _ZNKSt9type_info7__equalERKS_; + } GLIBCXX_3.4.29; # Symbols in the support library (libsupc++) have their own tag. -- cgit v1.1