public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.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 15:27:09 +0000	[thread overview]
Message-ID: <bug-113099-4-wXMg3tcf6S@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-113099-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113099

--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Peter Dimov from comment #7)
> You don't necessarily need dynamic_cast because facets are always installed
> and obtained by their exact type, not via a reference to base.

Is that true? std::use_facet<X> 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<char>, which overrides some members.
Code that does std::use_facet<std::ctype<char>>(loc) will get the user's facet,
but via reference to base.

> You can store
> the Facet* as given (like shared_ptr does), and return it.
> 
> The only reason dynamic_cast is needed here is because you can't static_cast
> from facet* to Facet* when virtual inheritance. But you are not required to
> store facet* in the actual container; you can store the original Facet* as
> void*.

An implementation could do that, but I don't think libstdc++ can do it now
without an ABI change.

  parent reply	other threads:[~2023-12-24 15:27 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-20 23:41 [Bug libstdc++/113099] New: " andysem at mail dot ru
2023-12-21  8:59 ` [Bug libstdc++/113099] " rguenth at gcc dot gnu.org
2023-12-21 21:49 ` redi at gcc dot gnu.org
2023-12-23  9:37 ` andysem at mail dot ru
2023-12-23  9:39 ` andysem at mail dot ru
2023-12-24 14:44 ` redi at gcc dot gnu.org
2023-12-24 14:46 ` redi at gcc dot gnu.org
2023-12-24 15:04 ` pdimov at gmail dot com
2023-12-24 15:27 ` redi at gcc dot gnu.org [this message]
2023-12-24 15:30 ` redi at gcc dot gnu.org
2023-12-24 15:40 ` pdimov at gmail dot com
2023-12-24 16:22 ` andysem at mail dot ru
2023-12-26 12:31 ` redi at gcc dot gnu.org
2023-12-26 15:20 ` andysem at mail dot ru
2024-01-03 12:38 ` redi at gcc dot gnu.org
2024-01-03 12:43 ` redi at gcc dot gnu.org
2024-01-05 10:23 ` cvs-commit at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-113099-4-wXMg3tcf6S@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).