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

std::filebuf::overflow(EOF) writes EOF to file in unbuffered mode

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.1.3, 4.1.4
    • 4.2.0
    • 27. Input/Output
    • None

    Description

      The program below should run successfully to completion but instead it aborts (both in 4.1.3 and on trunk):

      $ cat t.cpp && make t && LD_LIBRARY_PATH=../lib ./t
      #include <cassert>
      #include <fstream>
      #include <ios>

      int main ()
      {
      struct: std::filebuf {
      int_type overflow (int_type c)

      { return std::filebuf::overflow (c); }

      } buf;

      buf.open ("file", std::ios::out);
      buf.pubsetbuf (0, 0);
      buf.overflow (std::filebuf::traits_type::eof ());
      buf.close ();

      std::ifstream in ("file");
      assert (std::istream::traits_type::eof () == in.get ());
      }
      gcc -c -I/amd/devco/sebor/stdcxx-4.1.3/include/ansi -D_RWSTDDEBUG -pthread -D_RWSTD_USE_CONFIG -I/build/sebor/stdcxx-4.1.3-gcc-3.4.3_6-15D/include -I/amd/devco/sebor/stdcxx-4.1.3/include -I/amd/devco/sebor/stdcxx-4.1.3/examples/include -pedantic -nostdinc++ -g -m64 -Wall -W -Wcast-qual -Winline -Wshadow -Wwrite-strings -Wno-long-long -Wcast-align t.cpp
      gcc t.o -o t -pthread -m64 -L/build/sebor/stdcxx-4.1.3-gcc-3.4.3_6-15D/lib -lstd15D -lsupc++ -lm
      t: t.cpp:19: int main(): Assertion `std::istream::traits_type::eof () == in.get ()' failed.
      Aborted

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: