https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113099
--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> --- (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 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. And I guess if the user's derived facet uses virtual inheritance from std::locale::facet, then this could break with the static_cast<std::ctype<char>*> in libstdc++ today. Hmm.