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

[gcc 3.2.3/Linux] std::wfilebuf extracts more than 1 character from a 1 byte file

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 4.1.3, 4.2.0
    • 4.2.1
    • 27. Input/Output
    • None
    • gcc 3.2.3 on Linux

    • Incorrect Behavior

    Description

      I get an an abort when I run the following program on Linux.

      #include <cassert>
      #include <fstream>
      #include <iostream>
      
      int main ()
      {
          {
              std::filebuf fb;
              fb.open ("file", std::ios::out);
              fb.sputc ('a');
          }
      
          std::wfilebuf fb;
          fb.pubimbue (std::locale ("en_US.UTF-8"));
          fb.open ("file", std::ios::in);
      
          const int c[] = { fb.sbumpc (), fb.sgetc () };
          std::cout << c [0] << ' ' << c [1] << std::endl;
      
          assert (L'a' == c [0]);
          assert (std::wfilebuf::traits_type::eof () == c [1]);
      }
      
      test: test.cpp:21: int main(): Assertion `std::wfilebuf::traits_type::eof () == c [1]' failed.
      Aborted
      

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: