From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 88DD03858C2F; Sun, 24 Dec 2023 14:44:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 88DD03858C2F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1703429087; bh=6NPLjMBT90tiQ0tpwwW+Q82GLog2pi5Vjtw8v0f0QpY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=eo5uvfTN21X2/7lw6HrPQTr4hERGKGwyHi345k0QtydajL2RGEKv7aRB88yguFVxv SzZCZ4jKlcgb6tSKCuomKgj6URiO0EK0xKJz2L2bBErjLs4T7RTXgMxlqVArEqqQqX jX+TUsBNUD1ftp58g6vC7ww4grcax1T3ICXTyNLc= 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: Sun, 24 Dec 2023 14:44:44 +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 #5 from Jonathan Wakely --- I'm not sure what you mean by "the compiler is free to generate code that t= akes it into account." Takes what into account? What problem does that freedom cause? The locale facet instantiations are compiled as C++11 (but other parts of t= he library are compiled as C++17 or newer). We should do this so it uses if-constexpr for everything except C++98: --- a/libstdc++-v3/include/bits/locale_classes.tcc +++ b/libstdc++-v3/include/bits/locale_classes.tcc @@ -87,6 +87,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __s2.data(), __s2.data() + __s2.length()) <= 0); } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wc++17-extensions" template inline const _Facet* __try_use_facet(const locale& __loc) _GLIBCXX_NOTHROW @@ -97,7 +99,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // We know these standard facets are always installed in every locale // so dynamic_cast always succeeds, just use static_cast instead. #define _GLIBCXX_STD_FACET(...) \ - if _GLIBCXX17_CONSTEXPR (__is_same(_Facet, __VA_ARGS__)) \ + if _GLIBCXX_CONSTEXPR (__is_same(_Facet, __VA_ARGS__)) \ return static_cast(__facets[__i]) _GLIBCXX_STD_FACET(ctype); @@ -145,6 +147,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return static_cast(__facets[__i]); #endif } +#pragma GCC diagnostic pop /** * @brief Test for the presence of a facet.=