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

[LWG #596] std::filebuf::open(..., ios::app) unexpectedly succeeds

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Trivial
    • Resolution: Unresolved
    • 4.1.2, 4.1.3
    • 4.3.0
    • 27. Input/Output
    • None
    • all

    • Incorrect Behavior

    Description

      According to filebuf.members, p2, filebuf::open(const char*, openmode mode) is not some combination of the flags listed in Table 113 the call is supposed to fail. Since ios::app only appears in conjunction with ios::out (and ios::binary|ios::out) the call in the program below should fail.

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

      int main ()
      {
      std::filebuf fb;

      const std::filebuf* const pfb = fb.open ("dummy", std::ios::app);

      assert (0 == pfb);
      }
      gcc -c -I/build/sebor/dev/stdlib/include/ansi -D_RWSTDDEBUG -D_RWSTD_USE_CONFIG -I/build/sebor/dev/stdlib/include -I/build/sebor/gcc-4.1.0-11s/include -I/build/sebor/dev/stdlib/../rwtest -I/build/sebor/dev/stdlib/../rwtest/include -I/build/sebor/dev/stdlib/tests/include -pedantic -nostdinc++ -g -W -Wall -Wcast-qual -Winline -Wshadow -Wwrite-strings -Wno-long-long t.cpp
      gcc t.o -o t -L/build/sebor/gcc-4.1.0-11s/rwtest -lrwtest11s -L/build/sebor/gcc-4.1.0-11s/lib -lstd11s -lsupc++ -lm
      Assertion failed: 0 == pfb, file t.cpp, line 10
      Abort (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:

              Time Tracking

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