From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29406 invoked by alias); 24 Dec 2001 09:45:56 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 29374 invoked by uid 61); 24 Dec 2001 09:45:56 -0000 Date: Mon, 24 Dec 2001 01:45:00 -0000 Message-ID: <20011224094556.29373.qmail@sources.redhat.com> To: gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, kingleo@gmx.at, nobody@gcc.gnu.org, paolo@gcc.gnu.org From: paolo@gcc.gnu.org Reply-To: paolo@gcc.gnu.org, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, kingleo@gmx.at, nobody@gcc.gnu.org, paolo@gcc.gnu.org, gcc-gnats@gcc.gnu.org X-Mailer: gnatsweb 2.9.3 Subject: Re: libstdc++/5180: seekp() on fstreams opened in read only mode X-SW-Source: 2001-12/txt/msg01095.txt.bz2 List-Id: 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 #include #include 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