public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "tkoenig at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libfortran/35132] New: Formatted stream I/O write should truncate
Date: Thu, 07 Feb 2008 22:32:00 -0000 [thread overview]
Message-ID: <bug-35132-10391@http.gcc.gnu.org/bugzilla/> (raw)
>From c.l.f, Richard Maine:
2003 9.2.3.3, "File position after data
transfer", 3rd para
"For a formatted stream output statement, if no error condition
occurred, the terminall point of the file is set to the highest-numbered
position to which data was transferred by the statement."
Currently, we don't. The following program shouldn't work:
program main
implicit none
character(len=6) :: c
integer :: i
open(20,file="foo.txt",form="formatted",access="stream")
write(20,'(A)') '123456'
write(20,'(A)') 'abcdef'
write(20,'(A)') 'qwerty'
rewind 20
! Skip over the first line
read(20,'(A)') c
! Save the position
inquire(20,pos=i)
! Read in the complete line...
read(20,'(A)') c
! Write out the first four characters
write(20,'(A)',pos=i,advance="no") 'ASDF'
! Fill up the rest of the line. Here, we know the length. If we
! don't, things will be a bit more complicated.
write(20,'(A)') c(5:6)
! Copy the file to standard output
rewind 20
do i=1,3
read(20,'(A)') c
print '(A)',c
end do
close (20)
end program main
It currently prints
123456
ASDFef
qwerty
which is wrong.
--
Summary: Formatted stream I/O write should truncate
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: libfortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tkoenig at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35132
next reply other threads:[~2008-02-07 22:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-07 22:32 tkoenig at gcc dot gnu dot org [this message]
2008-02-07 22:52 ` [Bug libfortran/35132] " burnus at gcc dot gnu dot org
2008-02-08 20:48 ` jvdelisle at gcc dot gnu dot org
2008-02-08 21:41 ` jvdelisle at gcc dot gnu dot org
2008-02-09 21:49 ` tkoenig at gcc dot gnu dot org
2008-02-10 11:43 ` tkoenig at gcc dot gnu dot org
2008-02-10 13:52 ` jvdelisle at gcc dot gnu dot org
2008-02-17 10:11 ` tkoenig at gcc dot gnu dot org
2008-02-21 2:28 ` jvdelisle at gcc dot gnu dot org
2008-02-21 2:35 ` jvdelisle at gcc dot gnu dot org
2008-02-21 2:46 ` jvdelisle at gcc dot gnu dot org
2008-02-21 2:54 ` jvdelisle at gcc dot gnu dot org
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-35132-10391@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).