This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Recent strstream regression: reversion needed?
- From: Benjamin Kosnik <bkoz at redhat dot com>
- To: Paolo Carlini <pcarlini at unitus dot it>
- Cc: libstdc++ at gcc dot gnu dot org, bkoz at redhat dot com
- Date: Wed, 5 Jun 2002 01:25:04 -0700
- Subject: Re: Recent strstream regression: reversion needed?
- Organization: Red Hat / Paris
- References: <3CFBACEB.7050109@unitus.it>
- Reply-to: bkoz at nabi dot net
I'm convinced that removing the strstream code and just typedefing
strstream to stringstream<char>, istrstream to istringstream<char>,
ostrstream to ostringstream<char>, etc, would work much better than the
present solution. I think it was discussed but I'm not quite sure why
the current solution is in place instead.
In addition, this stuff should not be in std::.
I'll add that to the TODO list as an ABI-breaking item to consider.
> I see the point of your patch and, whereas I'm still convinced that
> simply returning to the old code would be a simpler and cleaner
> solution (note that, in the old code, ~strstreambuf() *calls*
> _M_free(eback()); therefore the memory *is* deallocated) I was
> confident that your patch would work.
The problem is when setbuf is used with a user-defined buffer. That's
when things get lost, and why using eback is a bad idea.
> However, to my puzzlement, your patch doesn't work for a modified
> testcase writing more, say the first 1000 integers and we are back to
> a segfault:
>
> #include <strstream.h>
>
> int main()
> {
> strstream s;
> for (unsigned i=0 ; i!= 1000 ; ++i)
> s << i << std::endl;
> s << std::ends;
>
> return 0;
> }
I'll look at this, but I'll be travelling the next couple of days.
-benjamin