> -----Original Message-----
> From: Martin Sebor (JIRA) [mailto:[EMAIL PROTECTED]
> Sent: Thursday, May 24, 2007 1:14 AM
> To: [email protected]
> Subject: [jira] Created: (STDCXX-427) SIGSEGV in istringstream::str()
>
> SIGSEGV in istringstream::str()
> -------------------------------
>
> Key: STDCXX-427
> URL: https://issues.apache.org/jira/browse/STDCXX-427
> Project: C++ Standard Library
> Issue Type: Bug
> Components: 27. Input/Output
> Affects Versions: 4.2
> Environment: gcc-3.3.3 on Linux
> Reporter: Martin Sebor
> Priority: Critical
>
>
> This only happens on trunk, not with 4.1.3:
>
> $ rm t.o && cat t.cpp && make t && gdb -q t #include
> <cassert> #include <sstream> #include <string>
>
> int main ()
> {
> using namespace std;
>
> string str ("test");
>
> istringstream isstr;
>
> isstr.str (str);
>
> assert (isstr.str ().length () == str.length ());
>
> assert (isstr.str () == str);
> }
The bug also reproduced on MSVC. The proposed patch below:
-----------------------
Index: sstream
===================================================================
--- sstream (revision 541218)
+++ sstream (working copy)
@@ -126,7 +126,7 @@
_C_string_type str () const {
const _RWSTD_SIZE_T __slen = (this->egptr () < this->pptr () ?
- this->pptr () : this->egptr ()) - this->pbase ();
+ this->pptr () : this->egptr ()) - this->_C_buffer;
return _C_string_type (this->_C_buffer, __slen);
}
-----------------------
Farid.