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

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.2.0
    • Fix Version/s: 4.2.0
    • Component/s: 27. Input/Output
    • Labels:
      None
    • Environment:

      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

              • Assignee:
                farid Farid Zaripov
                Reporter:
                farid Farid Zaripov
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: