[Bug libstdc++/13007] basic_streambuf::pubimbue, imbue wrong
peturr02 at ru dot is
gcc-bugzilla@gcc.gnu.org
Wed Nov 12 08:09:00 GMT 2003
------- Additional Comments From peturr02 at ru dot is 2003-11-12 08:09 -------
This bit is wrong:
{
locale __tmp(this->getloc());
this->imbue(__loc);
+ if (__tmp != __loc)
+ _M_buf_locale = __loc;
return __tmp;
}
Consider an implementation of imbue that caches a facet:
class Foo : public streambuf {
ctype<char>* ct;
void imbue(const locale& loc) {
ct = &use_facet<ctype<char> >(loc);
}
};
This is then called like this:
Foo foo;
foo.pubimbue(locale("is_IS"));
foo.pubimbue(locale("is_IS"));
In the first call to pubimbue the locale is set correctly and all is well.
In the second call the temporary object is passed to imbue and a reference
to the facet stored, but streambuf does not store a copy of the temporary
and so the cached facet becomes a dangling pointer.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13007
More information about the Gcc-bugs
mailing list