This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: libstdc++/5180: seekp() on fstreams opened in read only mode


Synopsis: seekp() on fstreams opened in read only mode

Responsible-Changed-From-To: unassigned->paolo
Responsible-Changed-By: paolo
Responsible-Changed-When: Mon Dec 24 01:45:56 2001
Responsible-Changed-Why:
    Taking care of it.
State-Changed-From-To: open->feedback
State-Changed-By: paolo
State-Changed-When: Mon Dec 24 01:45:56 2001
State-Changed-Why:
    I think the behaviour you are reporting is standard
    conforming. In fact, after seekp(0) the failbit is set
    and the standard prescribes that all IOStreams operations
    have no effect once the stream state indicates an error
    situation. Compare the behaviour of the testcase with that
    (identical) of:
    
    #include <iostream>
    #include <fstream>
    #include <string>
    
    using namespace std;
    
    int main( int argc, char** argv )
    {
    
      if( argc != 2)
        return 1;
    
      fstream in( argv[1], std::ios::in );
    
      if( !in )
        {
          cout << "cannot open file " << endl;
          return 2;
        }
    
      /*
      in.seekp(0); // <<<<<<<
    
      if (in.rdstate() & ios::failbit)
        {
          cout << "fail" << endl;
          in.clear();
        }
      */
    
      while( !in.eof() )
        {
          string s;
          //getline( in, s );
          cout << s << endl;;
        }
    
      return 0;
    };

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5180


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]