This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [RFC] libstdc++/9404 or weird stringbuf internals
- From: Benjamin Kosnik <bkoz at redhat dot com>
- To: Paolo Carlini <pcarlini at unitus dot it>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Wed, 12 Feb 2003 19:57:09 -0600
- Subject: Re: [RFC] libstdc++/9404 or weird stringbuf internals
- References: <3E496CC5.3000009@unitus.it>
>Upon the first one, overflow is called since there isn't an
>allocated string. Therefore overflow allocates one, then calls
>sputc again, as prescribed by the standard (well, not really, in
>fact it does *this->_M_out_cur = traits_type::to_char_type(__c);
>which is not the same thing, but this is a minor nit which
>could be easily fixed with some performance implications...).
This should be fixed, and is an error in the current implementation.
You can test this with a derived streambuf with a sputc member. I didn't
do that, but it should probably be done.
As for the rest, it is an error with _M_out_end being set incorrectly.
Petur's right, if epptr() == pptr(), overflow, but that should not be
the case for the seconf sputc.
// there is no condition in the standard that requires this.
// in fact, this should not be true.
assert(dsbuf.pub_epptr() == dsbuf.pub_pptr());
// the standard says nothing about a mandated call to overflow here.
called = false;
dsbuf.sputc('a');
assert(called); // 20030212 fail
Don't know if this is that helpful.
-benjamin