From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0640F385840D; Tue, 26 Dec 2023 12:31:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0640F385840D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1703593889; bh=N0ww95TxGhoF6cjCQ0GH1PWJL278AHOAowedfB5Fhcw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=mp7FmIk02trYyUFylg9I++3NiOO+pUMC8oN27LzKoSV9BmlZZHRg8RHQ7RHTpEeMz x1cfRatKkd/8dxr17y3fLLMEcOsbLHao8UcJCLcFnVTEgFIiTZVMlaTfVO4saJMIbc b9i6+69+NGJSvgv8mdJs2HgWJAbeSVZpziT76bRM= 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: Tue, 26 Dec 2023 12:31:25 +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: UNCONFIRMED 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113099 --- Comment #12 from Jonathan Wakely --- (In reply to andysem from comment #11) > > I'm not sure what you mean by "the compiler is free to generate code th= at takes it into account." Takes what into account? What problem does that = freedom cause? >=20 > I mean the compiler could move (some part of) dynamic_cast to precede the > check for the standard facet. I.e. of something like this: >=20 > template< typename _Facet > > const _Facet* __try_use_facet(locale const& loc) > { > const size_t __i =3D _Facet::id._M_id(); > const locale::facet** __facets =3D __loc._M_impl->_M_facets; > const _Facet* __dyn_facet =3D __dynamic_cast< const _Facet* > >(__facets[__i]); >=20 > // checks for every standard facet type > if (__is_same(_Facet, ...)) > return static_cast(__facets[__i]); >=20 > return __dyn_facet; > } But why? Maybe I'm being slow but I still don't understand what problem is being solved here. Also this would defeat the optimization that avoids the unnecessary overhea= d of dynamic_cast for standard facets. > AFAIK, the standard or libstdc++ docs do not require RTTI for std::locale= to > function. The standard requires RTTI, period. Using -fno-rtti is completely non-stand= ard and so the standard has nothing to say about it.=