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

std::operator<<(ostream, string) doesn't call width(0) on ios_base::failure

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 4.1.3
    • 4.2.0
    • 21. Strings
    • None
    • all

    Description

      The following test fails:

      #include <iostream>
      #include <strstream>
      #include <string>
      #include <cassert>

      int main(int argc, char* argv[])
      {
      std::string str ("abcdefghijk");

      char buf[10];
      std::ostrstream os (buf, sizeof(buf));
      const std::streamsize width = 2;

      os.width (width);
      os.exceptions (std::ios_base::failbit | std::ios_base::badbit);

      try

      { os << str; }

      catch (std::ios_base::failure&) {
      }

      assert (0 == os.width ());
      return 0;
      }

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: