This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
"scratch" file bug in g77/egcs1.1b
- To: egcs-bugs at cygnus dot com
- Subject: "scratch" file bug in g77/egcs1.1b
- From: Mako Sasaki <sasaki at tyo dot sci dot jri dot co dot jp>
- Date: Thu, 24 Sep 1998 11:34:01 +0900
I found that file I/O operations for I/O units opened as STATUS='SCRATCH' and FORM='FORMATTED' do not work correctly in g77/egcs1.1b;
* ==== Example ========================================
character*32 ll
open(10,form='formatted',status='scratch')
cccc open(10,form='formatted')
* --------------- write 10 lines first --------
do i=1,10
write(10,'("first ",i3)') i
end do
rewind 10
* --------------- write 5 lines after rewind --------
do i=1,5
write(10,'("second ",i3)') i
end do
rewind 10
* --------------- read lines until EOF ....
do i=1,1000
read(10,end=150,fmt='(a)') ll
write(*,*) ll
end do
150 continue
end
*============================================================
This program outputs the following lines when compiled with g77/egcs1.1b.
second 1
second 2
second 3
second 4
second 5
6
first 7
first 8
first 9
first 10
And expected output is only;
second 1
second 2
second 3
second 4
second 5
It seems that "REWIND" operation does not put EOF, and garbage from the first write/rewind cycle remains.
When compiled with g77/egcs1.0.3a, it works correctly.
Binary "scratch" files and formatted files not opened as "scratch" do not have such a problem.
===================================================================
Makoto Sasaki : The Japan Research Institute Ltd.
sasaki@tyo.sci.jri.co.jp