incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Farid Zaripov (JIRA)" <j...@apache.org>
Subject [jira] Created: (STDCXX-576) std::basic_streambuf<>::xsputn() incorrectly inserts the data, that is the part of the internal buffer
Date Thu, 04 Oct 2007 12:05:51 GMT
std::basic_streambuf<>::xsputn() incorrectly inserts the data, that is the part of the
internal buffer
------------------------------------------------------------------------------------------------------

                 Key: STDCXX-576
                 URL: https://issues.apache.org/jira/browse/STDCXX-576
             Project: C++ Standard Library
          Issue Type: Bug
          Components: 27. Input/Output
    Affects Versions: trunk
         Environment: All
            Reporter: Farid Zaripov
            Assignee: Farid Zaripov
             Fix For: 4.2


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 { return this->pbase (); }
};

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
------------------


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message