https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113099
--- Comment #7 from Peter Dimov <pdimov at gmail dot com> --- You don't necessarily need dynamic_cast because facets are always installed and obtained by their exact type, not via a 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*.