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

std::basic_stringbuf::overflow() writes characters at the begin, 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.1
    • 27. Input/Output
    • None
    • All

    • Incorrect Behavior

    Description

      From http://www.mail-archive.com/user@stdcxx.apache.org/msg00014.html

      The test below asserts on i = 513

      test.cpp
      #include <sstream>
      #include <string>
      #include <cassert>
      
      int main ()
      {
          std::ostringstream strm;
          std::string s;
      
          for (size_t i = 1; i <= 1024; ++i) {
              const char c = char (i);
              strm << c;
              s.push_back (c);
              assert (strm.str () == s);
          }
      
          return 0;
      }
      

      The test output:

      test: test.cpp:14: 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:

                Time Tracking

                  Estimated:
                  Original Estimate - 2h
                  2h
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 2h
                  2h