From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4266 invoked by alias); 26 Feb 2012 10:02:22 -0000 Received: (qmail 4238 invoked by uid 22791); 26 Feb 2012 10:02:19 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 26 Feb 2012 10:02:06 +0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/52387] I/O wrong output with nonadvancing output Date: Sun, 26 Feb 2012 10:13:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: CC Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-02/txt/msg02486.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D52387 Tobias Burnus changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |burnus at gcc dot gnu.org --- Comment #1 from Tobias Burnus 2012-02-26 10= :02:03 UTC --- (In reply to comment #0) > WRITE (10, '(A)') 'ABCDEFGHIJKL' At this point, the file contains: "ABCDEFGHIJKL" + . > REWIND 10 > READ (10, '(TR4)', ADVANCE=3D'NO') > WRITE (10, '(TL2, A)', ADVANCE=3D'NO') 'MNOP' And at that point, the file is trimmed to contain "ABCDMNOP" without . With other compilers (file "XXX"): NAG has at the end: "ABCDMNOP" plus line break. g95 has at the end: "ABCDEFGHIJKL" + + "MNOP" + no linebreak. pathscale: "ABCDMNOPIJKL" + linebreak. * * * Fortran 2008's C.6.2, paragraph 4 (nonnormative): "If the next I/O operation on a file after a nonadvancing write is a rewind, backspace, end file or close operation, the file is positioned implicitly a= fter the current record before an ENDFILE record is written to the file, that is= , a REWIND, BACKSPACE, or ENDFILE statement following a nonadvancing WRITE statement causes the file to be positioned at the end of the current output record before the endfile record is written to the file." And the paragraph 2 of Clause 9.3.4.2 is the following: "A nonadvancing input/output statement may position a record file at a character position within the current record, or a subsequent record (10.8.= 2). Using nonadvancing input/output, it is possible to read or write a record of the =0Cle by a sequence of input/output statements, each accessing a portio= n of the record. It is also possible to read variable-length records and be noti= =0Ced of their lengths. If a nonadvancing output statement leaves a file position= ed within a current record and no further output statement is executed for the file before it is closed or a BACKSPACE, ENDFILE, or REWIND statement is executed for it, the effect is as if the output statement were the corresponding advancing output statement." * * * At least looking at the normative text (9.3.4.2), I think NAG's result is correct: Namely, after writing "ABCDMNOP" the record is ended with a record marker (new line) and then it is trimmed (end file marker is written). Looking at the nonormative text, I get the conclusion Bob had: Namely that = the result should be "ABCDMNOPIJKL" followed by a new line and the endfile mark= er.