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

std::ios::copyfmt() doesn't copy tie(), getloc()

    XMLWordPrintableJSON

    Details

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

      all

    • Severity:
      Incorrect Behavior

      Description

      The following test fails with the latest trunk.

      $ cat t.cpp && make t && ./t
      #include <cstdio>
      #include <ios>
      #include <iosfwd>
      #include <locale>
      #include <ostream>
      
      #define ASSERT(expr)                                                    \
          (expr) ? (void)0                                                    \
          : (void)std::fprintf (stderr, "line %d: Assertion failed: %s\n",    \
                                __LINE__, #expr)
      
      int main ()
      {
          std::ios x ((std::streambuf*)1);
          x.tie ((std::ostream*)2);
      
          std::ios y (0);
      
          const std::ios::iostate     x_rdstate = x.rdstate ();
          const std::streambuf* const x_rdbuf   = x.rdbuf ();
      
          const std::locale loc =
              std::locale (std::locale::classic (), new std::numpunct<char>());
      
          y.tie (x.tie () + 1);
          y.exceptions (y.eofbit);
          y.flags (y.boolalpha | y.scientific);
          y.precision (x.precision () + 1);
          y.width (x.width () + 1);
          y.fill (x.fill () + 1);
          y.imbue (loc);
      
          ASSERT (x.tie ()        != y.tie ());
          ASSERT (x.getloc ()     != y.getloc ());
      
          x.copyfmt (y);
      
          ASSERT (x.rdbuf ()      == x_rdbuf);
          ASSERT (x.tie ()        == y.tie ());
          ASSERT (x.rdstate ()    == x_rdstate);
          ASSERT (x.exceptions () == y.exceptions ());
          ASSERT (x.flags ()      == y.flags ());
          ASSERT (x.precision ()  == y.precision ());
          ASSERT (x.width ()      == y.width ());
          ASSERT (x.fill ()       == y.fill ());
          ASSERT (x.getloc ()     == y.getloc ());
      }
      gcc -c -I/home/sebor/stdcxx/include/ansi -D_RWSTDDEBUG    -I/home/sebor/stdcxx/i
      nclude -I/build/sebor/stdcxx-gcc-4.1.2-11S-LVS/include -I/home/sebor/stdcxx/incl
      ude/ansi -I/build/sebor/PlumHall/lvs07a/conform -I/build/sebor/PlumHall/lvs07a/d
      st.3  -pedantic -nostdinc++ -g   -W -Wall -Wcast-qual -Winline -Wshadow -Wwrite-
      strings -Wno-long-long -Wcast-align    t.cpp
      gcc t.o -o t  -L/build/sebor/stdcxx-gcc-4.1.2-11S-LVS/lib  -lstd11S -lsupc++ -lm
       
      line 39: Assertion failed: x.tie () == y.tie ()
      line 46: Assertion failed: x.getloc () == y.getloc ()
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                sebor Martin Sebor
                Reporter:
                sebor Martin Sebor
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

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