This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/52387] New: I/O wrong output with nonadvancing output
- From: "burnus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 26 Feb 2012 08:35:01 +0000
- Subject: [Bug fortran/52387] New: I/O wrong output with nonadvancing output
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52387
Bug #: 52387
Summary: I/O wrong output with nonadvancing output
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: burnus@gcc.gnu.org
CC: jvdelisle@gcc.gnu.org
[Vaguely related: PR 52251]
Bob Corbett asked at c.l.f what the program below produces with the different
compilers. He thinks that the proper output should be:
ABCDMNOPIJKL
while gfortran produces
ABCDMNOP
(or actually, it [and NAG f95] produce [cf. modified program]:
>ABCDMNOP <
with trailing spaces.)
Reasoning:
---------------- <cut> ----------------
According to interpretation 000024 of the Fortran 95 standard
Page 136. At the end of the last paragraph of subclause 9.2.1.3.1
[136:33] add
If a nonadvancing output statement leaves a file positioned within
the 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 file is positioned after the
current record before the specified action is performed.
The corresponding statement in the Fortran 2008 standard is
paragraph 2 of Clause 9.3.4.2. Based on that statement and
on paragraph 4 of non-normative Clause C.6.2 of the
Fortran 2008 standard, my reading is that the output should
be
ABCDMNOPIJKL
---------------- </cut> ----------------
See complete thread at
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/694050b1806da367
Results of the various compilers:
Bob's expected result, Pathscale 4.0, Openf95 5.0, OpenUH/Open64
ABCDMNOPIJKL
gfortran (4.1 to 4.7), NAG 5.1,
ABCDMNOP
g95, Silverfrost ftn95, ifort 11.1/12.1
ABCDEFGHIJKL
sunf95 10/latest Oracle f95, IBM xlf, Microsoft V 3.31 (1985)
MNOP
Lahey:
ABCDMNOP
PROGRAM MAIN
CHARACTER*12 STR
OPEN (10, FILE='XXX', POSITION='REWIND')
WRITE (10, '(A)') 'ABCDEFGHIJKL'
REWIND 10
READ (10, '(TR4)', ADVANCE='NO')
WRITE (10, '(TL2, A)', ADVANCE='NO') 'MNOP'
REWIND 10
READ (10, '(A)') STR
PRINT '(3A)', STR
! PRINT '(3A)', '>',STR,'<'
CLOSE (10, STATUS='DELETE')
END