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

filebuf::sgetn() fails after sputn() in stdio mode

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 4.1.3
    • 4.1.4
    • 27. Input/Output
    • None
    • all

    Description

      The program below fails at runtime (std::ios::stdio is an extension of this implementation that forces the filebuf to use the stdio facilities for I/O instead of OS native calls).

      $ cat t.cpp && gmake t && ./t
      #include <fstream>
      #include <cassert>

      int main ()
      {
      std::filebuf fb;

      assert (0 != fb.open ("testfile.text", std::ios::out));
      assert (6 == fb.sputn ("ABCDEF", 6));
      assert (0 != fb.close ());

      assert (0 != fb.open ("testfile.text",
      std::ios::in | std::ios::out | std::ios::stdio));

      assert (3 == fb.sputn ("abc", 3));
      assert (-1 != fb.pubsync ());

      char buf [3] = "";
      assert (3 == fb.sgetn (buf, sizeof buf));
      assert (0 == std::filebuf::traits_type::compare ("DEF", buf, 3));
      }
      aCC -c -I/build/sebor/dev/stdlib/include/ansi -I/usr/include -D_RWSTDDEBUG -mt -D_RWSTD_USE_CONFIG -I/build/sebor/aCC-3.63-15s/include -I/build/sebor/dev/stdlib/include -I/build/sebor/dev/stdlib/../rwtest -I/build/sebor/dev/stdlib/../rwtest/include -I/build/sebor/dev/stdlib/tests/include -Aa +nostl -g +d +w +W392 +W655 +W684 +W818 +W819 +W849 t.cpp
      aCC t.o -o t -L/build/sebor/aCC-3.63-15s/rwtest -lrwtest15s -Aa +nostl -Wl,+s -Wl,+vnocompatwarnings -L/build/sebor/aCC-3.63-15s/lib -mt -L/build/sebor/aCC-3.63-15s/lib -lstd15s -lm
      Assertion failed: 0 == std::filebuf::traits_type::compare ("DEF", buf, 3), file t.cpp, line 20
      ABORT instruction (core dumped)

      Attachments

        Activity

          People

            sebor Martin Sebor
            sebor Martin Sebor
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 1h
                1h