From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 97AF13858286; Wed, 3 Jan 2024 12:43:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 97AF13858286 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1704285789; bh=XI+njYYrdZ3GgB6T/5edvWnC+aVIYHc1Gxj/lNAileE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=K8T9X8FcA+oiNcVNLaCM1iR5B3+BswSOUEcCm5Oyd2/d2GaxGuD6ia2TrNl/tdlLN ngm5BP/3P6o5Ucpi28ObJOOStl3i4v3hAuvXXNxLN7dOiSiKvEgGRHDtBOWlp3agIO vcwe/TkhpsGFDU9D9Z0+gt06QTU9OzxID8qYqy00= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/113099] locale without RTTI uses dynamic_cast before gcc 13.2 or has ODR violation since gcc 13.2 Date: Wed, 03 Jan 2024 12:43:08 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 11.4.0 X-Bugzilla-Keywords: ABI, documentation X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: FIXED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.2 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113099 --- Comment #15 from Jonathan Wakely --- (In reply to Jonathan Wakely from comment #8) > (In reply to Peter Dimov from comment #7) > > You don't necessarily need dynamic_cast because facets are always insta= lled > > and obtained by their exact type, not via a reference to base. >=20 > Is that true? std::use_facet will return a reference to a facet with > X::id but it could actually be something derived from X. e.g. a user can > install their own facet derived from std::ctype, which overrides so= me > members. Code that does std::use_facet>(loc) will get the > user's facet, but via reference to base. And conversely, for std::use_facet the locale might contain a base class= of Y, with the same id as Y::id, but there is no Y present. For example, given= the OP's my_codecvt, the following code must throw std::bad_cast: std::locale loc; (void) std::use_facet(loc); There is no my_codecvt present. There is a facet with the same id, but its dynamic type is std::codecvt not my_codecvt. I don't see a way to avoid using dynamic_cast without an ABI change to the std::locale in libstdc++.=