https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113099
--- Comment #12 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to andysem from comment #11) > > I'm not sure what you mean by "the compiler is free to generate code that > > takes it into account." Takes what into account? What problem does that > > freedom cause? > > 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: > > template< typename _Facet > > const _Facet* __try_use_facet(locale const& loc) > { > const size_t __i = _Facet::id._M_id(); > const locale::facet** __facets = __loc._M_impl->_M_facets; > const _Facet* __dyn_facet = __dynamic_cast< const _Facet* > >(__facets[__i]); > > // checks for every standard facet type > if (__is_same(_Facet, ...)) > return static_cast<const _Facet*>(__facets[__i]); > > 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 overhead 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-standard and so the standard has nothing to say about it.