public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/19451] New: Some read and write confusion with a read-only file
@ 2005-01-14 19:57 Thomas dot Koenig at online dot de
2005-01-14 20:01 ` [Bug libfortran/19451] " pinskia at gcc dot gnu dot org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Thomas dot Koenig at online dot de @ 2005-01-14 19:57 UTC (permalink / raw)
To: gcc-bugs
$ cat open+write.f90
program main
character(len=10) a
call system("rm -f asdf.dat; touch asdf.dat; chmod u-w asdf.dat")
open(file="asdf.dat",unit=10,err=999,action="read")
write(10,*,err=20) "Hello, world"
print *,"write to read-only file succeeded"
call abort
20 continue
! rewind(10)
read(10,'(A)',end=30,err=999) a
print *,"read from empty file succeeded"
call abort
999 continue
print *,"error reading from read-only file"
call abort
30 continue
print *,"Success!"
end
$ gfortran open+write.f90
$ ./a.out
error reading from read-only file
Aborted
Uncommenting the rewind statement leads to
$ ./a.out
read from empty file succeeded
Aborted
$ gfortran -v ; gfortran -dumpmachine
Using built-in specs.
Configured with: ../gcc-4.0-20050109/configure --prefix=/home/zfkts
--enable-languages=c,c++,f95
Thread model: posix
gcc version 4.0.0 20050109 (experimental)
ia64-unknown-linux-gnu
--
Summary: Some read and write confusion with a read-only file
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: Thomas dot Koenig at online dot de
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19451
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libfortran/19451] Some read and write confusion with a read-only file
2005-01-14 19:57 [Bug fortran/19451] New: Some read and write confusion with a read-only file Thomas dot Koenig at online dot de
@ 2005-01-14 20:01 ` pinskia at gcc dot gnu dot org
2005-01-15 8:08 ` [Bug libfortran/19451] Read after a write with a read only file pinskia at gcc dot gnu dot org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-14 20:01 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Component|fortran |libfortran
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19451
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libfortran/19451] Read after a write with a read only file
2005-01-14 19:57 [Bug fortran/19451] New: Some read and write confusion with a read-only file Thomas dot Koenig at online dot de
2005-01-14 20:01 ` [Bug libfortran/19451] " pinskia at gcc dot gnu dot org
@ 2005-01-15 8:08 ` pinskia at gcc dot gnu dot org
2005-01-19 21:35 ` Thomas dot Koenig at online dot de
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-15 8:08 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-01-15 08:08 -------
Confirmed, changing the summary a little more.
Also if the file contained anything, we seg fault when finishing the write (which seems wrong).
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2005-01-15 08:08:37
date| |
Summary|Some read and write |Read after a write with a
|confusion with a read-only |read only file
|file |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19451
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libfortran/19451] Read after a write with a read only file
2005-01-14 19:57 [Bug fortran/19451] New: Some read and write confusion with a read-only file Thomas dot Koenig at online dot de
2005-01-14 20:01 ` [Bug libfortran/19451] " pinskia at gcc dot gnu dot org
2005-01-15 8:08 ` [Bug libfortran/19451] Read after a write with a read only file pinskia at gcc dot gnu dot org
@ 2005-01-19 21:35 ` Thomas dot Koenig at online dot de
2005-01-19 22:17 ` Thomas dot Koenig at online dot de
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Thomas dot Koenig at online dot de @ 2005-01-19 21:35 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From Thomas dot Koenig at online dot de 2005-01-19 21:35 -------
(In reply to comment #1)
> Confirmed, changing the summary a little more.
>
> Also if the file contained anything, we seg fault when finishing the write
(which seems wrong).
Here's a test case for that:
$ cat open+write2.f90
program main
call system("rm -f asdf.dat; echo foo > asdf.dat; chmod u-w asdf.dat")
open(file="asdf.dat",unit=10,action="read")
write(10,*,iostat=i) "Hello, world"
end
$ gfortran open+write2.f90
$ ./a.out
Segmentation fault
Same thing with iostat= as with err=. Without it, things work:
$ cat open+write3.f90
program main
call system("rm -f asdf.dat; echo foo > asdf.dat; chmod u-w asdf.dat")
open(file="asdf.dat",unit=10,action="read")
write(10,*) "Hello, world"
end
$ gfortran open+write3.f90
$ ./a.out
At line 4 of file open+write3.f90
Fortran runtime error: Cannot write to file opened for READ
... which is correct behaviour.
After some poking around, it seems that finalize_transfer()
insists on doing something even if ioparm.library_return
is not equal to LIBRARY_OK.
I've tried out the following patch:
Index: transfer.c
===================================================================
RCS file: /cvsroot/gcc/gcc/libgfortran/io/transfer.c,v
retrieving revision 1.26
diff -c -r1.26 transfer.c
*** transfer.c 15 Jan 2005 08:10:19 -0000 1.26
--- transfer.c 19 Jan 2005 21:26:07 -0000
***************
*** 1383,1388 ****
--- 1383,1391 ----
static void
finalize_transfer (void)
{
+ if (ioparm.library_return != LIBRARY_OK)
+ return;
+
if ((ionml != NULL) && (ioparm.namelist_name != NULL))
{
if (ioparm.namelist_read_mode)
which didn't seem to do any harm (no testcase failures) and
which appears to fix the problem, but I don't know wether this
introduces any cleanup issues.
Thomas
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19451
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libfortran/19451] Read after a write with a read only file
2005-01-14 19:57 [Bug fortran/19451] New: Some read and write confusion with a read-only file Thomas dot Koenig at online dot de
` (2 preceding siblings ...)
2005-01-19 21:35 ` Thomas dot Koenig at online dot de
@ 2005-01-19 22:17 ` Thomas dot Koenig at online dot de
2005-01-23 2:21 ` cvs-commit at gcc dot gnu dot org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Thomas dot Koenig at online dot de @ 2005-01-19 22:17 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From Thomas dot Koenig at online dot de 2005-01-19 22:17 -------
Patch:
http://gcc.gnu.org/ml/gcc-patches/2005-01/msg01266.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19451
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libfortran/19451] Read after a write with a read only file
2005-01-14 19:57 [Bug fortran/19451] New: Some read and write confusion with a read-only file Thomas dot Koenig at online dot de
` (3 preceding siblings ...)
2005-01-19 22:17 ` Thomas dot Koenig at online dot de
@ 2005-01-23 2:21 ` cvs-commit at gcc dot gnu dot org
2005-01-24 20:03 ` Thomas dot Koenig at online dot de
2005-04-20 2:06 ` pinskia at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-01-23 2:21 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2005-01-23 02:20 -------
Subject: Bug 19451
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: pbrook@gcc.gnu.org 2005-01-23 02:18:34
Modified files:
gcc/testsuite : ChangeLog
libgfortran : ChangeLog
libgfortran/io : transfer.c
Added files:
gcc/testsuite/gfortran.dg: open_readonly_1.f90
Log message:
2005-01-22 Thomas Koenig <Thomas.Koenig@online.de>
PR libfortran/19451
* io/transfer.c (finalize_transfer): Don't do anything if
there is an error condition.
* open_readonly_1.f90: New test.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4925&r2=1.4926
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/open_readonly_1.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/ChangeLog.diff?cvsroot=gcc&r1=1.151&r2=1.152
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/io/transfer.c.diff?cvsroot=gcc&r1=1.28&r2=1.29
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19451
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libfortran/19451] Read after a write with a read only file
2005-01-14 19:57 [Bug fortran/19451] New: Some read and write confusion with a read-only file Thomas dot Koenig at online dot de
` (4 preceding siblings ...)
2005-01-23 2:21 ` cvs-commit at gcc dot gnu dot org
@ 2005-01-24 20:03 ` Thomas dot Koenig at online dot de
2005-04-20 2:06 ` pinskia at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: Thomas dot Koenig at online dot de @ 2005-01-24 20:03 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From Thomas dot Koenig at online dot de 2005-01-24 20:03 -------
Fixed.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19451
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libfortran/19451] Read after a write with a read only file
2005-01-14 19:57 [Bug fortran/19451] New: Some read and write confusion with a read-only file Thomas dot Koenig at online dot de
` (5 preceding siblings ...)
2005-01-24 20:03 ` Thomas dot Koenig at online dot de
@ 2005-04-20 2:06 ` pinskia at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-20 2:06 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |4.0.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19451
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2005-04-20 2:02 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-14 19:57 [Bug fortran/19451] New: Some read and write confusion with a read-only file Thomas dot Koenig at online dot de
2005-01-14 20:01 ` [Bug libfortran/19451] " pinskia at gcc dot gnu dot org
2005-01-15 8:08 ` [Bug libfortran/19451] Read after a write with a read only file pinskia at gcc dot gnu dot org
2005-01-19 21:35 ` Thomas dot Koenig at online dot de
2005-01-19 22:17 ` Thomas dot Koenig at online dot de
2005-01-23 2:21 ` cvs-commit at gcc dot gnu dot org
2005-01-24 20:03 ` Thomas dot Koenig at online dot de
2005-04-20 2:06 ` pinskia at gcc dot gnu dot org
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).