This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/52540] std::use_facet throws bad_cast when compiled with _GLIBCXX_DEBUG
- From: "ktietz at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 09 Mar 2012 12:00:00 +0000
- Subject: [Bug libstdc++/52540] std::use_facet throws bad_cast when compiled with _GLIBCXX_DEBUG
- Auto-submitted: auto-generated
- References: <bug-52540-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52540
--- Comment #4 from Kai Tietz <ktietz at gcc dot gnu.org> 2012-03-09 12:00:00 UTC ---
Issue happens in
include/bits/locale_classes.tcc:
template<typename _Facet>
const _Facet&
use_facet(const locale& __loc)
{
const size_t __i = _Facet::id._M_id();
const locale::facet** __facets = __loc._M_impl->_M_facets;
134 if (__i >= __loc._M_impl->_M_facets_size || !__facets[__i])
135 __throw_bad_cast();
#ifdef __GXX_RTTI
return dynamic_cast<const _Facet&>(*__facets[__i]);
#else
return static_cast<const _Facet&>(*__facets[__i]);
#endif
}
The variable __i has value 30, but __loc.M_impl->_M_factes_size is just 28.