This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Recent strstream regression: reversion needed?
- From: Paolo Carlini <pcarlini at unitus dot it>
- To: bkoz at nabi dot net
- Cc: libstdc++ at gcc dot gnu dot org, bkoz <bkoz at redhat dot com>
- Date: Mon, 03 Jun 2002 19:52:43 +0200
- Subject: Re: Recent strstream regression: reversion needed?
No. It's necessary. That memory is allocated, it needs to be cleaned up.
Try adding
_M_buf = buf;
in strstreambuf::overflow.
I've a patch attached, but I have to run now. It's the above, with a
strstream reformat. You might check it out if you're interested. I'll
try to finish it up tomorrow. I think it'll do the job.
Hi Benjamin,
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.
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;
}
In the next hours I hope to make progress in understanding /why/!
Ciao, Paolo.