Uploaded image for project: 'C++ Standard Library'
  1. C++ Standard Library
  2. STDCXX-515

std::basic_streambuf<>::xsputn() writes characters at the end, but not at the current position if reallocation of internal buffer occurs

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.2.0
    • 4.2.0
    • 27. Input/Output
    • None
    • All

    Description

      The test below asserts on i == 512.

      test.cpp
      #include <sstream>
      #include <string>
      #include <cassert>
      
      int main ()
      {
          for (size_t i = 1; i <= 1024; ++i) {
              std::stringstream strm;
              std::string s (i, 'a');
              strm << s;
              strm.seekp (-1, std::ios::cur);
              s.erase (0, 1);
              strm << "bc";
              s.append ("bc");
              assert (strm.str () == s);
          }
      
          return 0;
      }
      

      The test output:

      test: test.cpp:15: int main (): Assertion `strm.str () == s' failed.
      Aborted
      

      Attachments

        Issue Links

          Activity

            People

              farid Farid Zaripov
              farid Farid Zaripov
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: