libstdc++/5180: seekp() on fstreams opened in read only mode
paolo@gcc.gnu.org
paolo@gcc.gnu.org
Mon Dec 24 10:20:00 GMT 2001
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
More information about the Gcc-bugs
mailing list