This is the mail archive of the mailing list for the libstdc++ project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: stringstreams and stringbuf in gcc 3.2.x

Hi Peter,

I am using stringstreams and was trying to manipulate the contents of the stream via the associated stringbuf (via the 'sputn' method).

As far as I leared by looking at the implementation in <sstream> the stream uses a string as buffer. But if one enlarges the buffer the (implicit?) assertion that the buffer size and the string size match seems to break.
By itself, this cannot be considered a bug anymore in the light of the resolution of DR169. However, we are aware that there are still some problems affecting our implementation in this area...

I have attached an example that produces the expected result with IRIX's CC and HP's aCC but displays a shortend version of the stream with gcc 3.2.
... luckily, that one which you have stumbled upon seems relatively easy to fix!

Do you have access to the sources of your gcc distribution? I'm testing the patch which you find attached, diffed against current mainline. It's just one line and you can also easily modify the sources you have by hand (3.2.2 perhaps?) and rebuild afterwards.

Can you possibly report here, then?

--- std_sstream.h.~1.13.~	2003-01-23 19:56:00.000000000 +0100
+++ std_sstream.h	2003-02-18 14:29:19.000000000 +0100
@@ -140,7 +140,7 @@
 	    // _M_string, and may not be the correct size of the
 	    // current stringbuf internal buffer.
 	    __size_type __len = _M_string.size();
-	    if (this->_M_out_cur > this->_M_out_beg)
+	    if (this->_M_out_end > this->_M_out_beg)
 	      __len = std::max(__size_type(this->_M_out_end 
 					   - this->_M_out_beg), __len);
 	    return __string_type(this->_M_out_beg, this->_M_out_beg + __len);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]