From issues-return-2170-apmail-stdcxx-issues-archive=stdcxx.apache.org@stdcxx.apache.org Fri Jun 13 16:03:08 2008 Return-Path: Delivered-To: apmail-stdcxx-issues-archive@locus.apache.org Received: (qmail 21410 invoked from network); 13 Jun 2008 16:03:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Jun 2008 16:03:08 -0000 Received: (qmail 24771 invoked by uid 500); 13 Jun 2008 16:03:10 -0000 Delivered-To: apmail-stdcxx-issues-archive@stdcxx.apache.org Received: (qmail 24758 invoked by uid 500); 13 Jun 2008 16:03:10 -0000 Mailing-List: contact issues-help@stdcxx.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@stdcxx.apache.org Delivered-To: mailing list issues@stdcxx.apache.org Received: (qmail 24747 invoked by uid 99); 13 Jun 2008 16:03:10 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Jun 2008 09:03:10 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Jun 2008 16:02:28 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 871EB234C13A for ; Fri, 13 Jun 2008 09:02:46 -0700 (PDT) Message-ID: <1413223732.1213372966539.JavaMail.jira@brutus> Date: Fri, 13 Jun 2008 09:02:46 -0700 (PDT) From: "Eric Lemings (JIRA)" To: issues@stdcxx.apache.org Subject: [jira] Commented: (STDCXX-969) std::basic_filebuf<>: sync() after close() calls __rw_fseek() on closed file In-Reply-To: <470920583.1213351365158.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/STDCXX-969?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12604919#action_12604919 ] Eric Lemings commented on STDCXX-969: ------------------------------------- For that matter, any file (or stream) operation on a closed file, aside from reopen, should do nothing (essentially a no-op), right? Does the standard specify this behavior as implementation-defined? > std::basic_filebuf<>: sync() after close() calls __rw_fseek() on closed file > ---------------------------------------------------------------------------- > > Key: STDCXX-969 > URL: https://issues.apache.org/jira/browse/STDCXX-969 > Project: C++ Standard Library > Issue Type: Bug > Components: 27. Input/Output > Affects Versions: 4.1.2, 4.1.3, 4.1.4, 4.2.0, 4.2.1 > Environment: All > Reporter: Farid Zaripov > Fix For: 4.2.2 > > Original Estimate: 1h > Remaining Estimate: 1h > > {code:title=test.cpp} > #include > int main (int argc, char* argv[]) > { > std::ifstream fs (argv [0], std::ios::binary); > char c; > fs.get (c); > fs.close (); > fs.sync (); > return 0; > } > {code} > In the test above the fs.sync() calls __rw_fseek(0, ...), that leads to lseek (-1, ...). > The proposed patch: > {code:title=fstream.cc.diff} > Index: include/fstream.cc > =================================================================== > --- include/fstream.cc (revision 667432) > +++ include/fstream.cc (working copy) > @@ -106,6 +106,8 @@ > _C_file = 0; > _C_cur_pos = _C_beg_pos = pos_type (off_type (-1)); > > + this->setg(0, 0, 0); > + this->setp(0, 0); > } > > // rethrow the caught exception > @@ -119,6 +121,9 @@ > // zero out the file pointer except when detaching fd > _C_file = 0; > _C_cur_pos = _C_beg_pos = pos_type (off_type (-1)); > + > + this->setg(0, 0, 0); > + this->setp(0, 0); > } > > return __retval; > {code} -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.