From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 079EF3858D28; Tue, 7 Dec 2021 13:47:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 079EF3858D28 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/103600] Cannot use typeid result in constant expressions Date: Tue, 07 Dec 2021 13:47:30 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Dec 2021 13:47:31 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103600 --- Comment #5 from Jonathan Wakely --- The new definition of operator=3D=3D will be something like: #if __GXX_TYPEINFO_EQUALITY_INLINE || __cplusplus > 202002L _GLIBCXX23_CONSTEXPR inline bool type_info::operator=3D=3D(const type_info& __arg) const _GLIBCXX_NOEXCEPT { if (__name =3D=3D __arg.__name) return true; if (!std::__is_constant_evaluated()) return false; #if !__GXX_TYPEINFO_EQUALITY_INLINE // ABI requires comparisons to be non-inline. return __equal(__arg); #elif !__GXX_MERGED_TYPEINFO_NAMES // Need to do string comparison. return __name[0] !=3D '*' && __builtin_strcmp (__name, __arg.name()) = =3D=3D 0; #else return false; #endif } # endif i.e. no strcmp for the constant evaluation case. During constant evaluation= I think we only need to handle types that are completely defined in the curre= nt TU, so we can ignore aliasing of _ZTi symbols, and we can ignore the proble= m of non-unique std::type_info objects. Within the TU they will be unique.=