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

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 4.1.3
    • Fix Version/s: 4.2.0
    • Component/s: 21. Strings
    • Labels:
      None
    • Environment:

      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

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

                Dates

                • Created:
                  Updated:
                  Resolved: