Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
All
-
Patch Available
-
Incorrect Behavior
Description
The test below aborts on assert.
test.cpp:
------------------
#include <sstream> // for stringbuf
#include <string> // for string
#include <cassert> // for assert()
struct PubBuf: std::stringbuf
{
char* Pbase () const
};
int main ()
{
// 512 is the default buffer size of the basic_stringbuf
std::string s (512, 'a');
std::stringbuf sbuf (s);
PubBuf& buf = (PubBuf&)sbuf;
std::streamsize res = buf.sputn (buf.Pbase (), 128);
s.append (s.begin (), s.begin () + 128);
const std::string& str = buf.str ();
assert (res == 128);
assert (str.size () == s.size ());
assert (str == s);
return 0;
}
------------------
The test output:
------------------
test: test.cpp:25: int main (): Assertion `str == s' failed.
Aborted
------------------