backspace/endfile combination bug

grhoden grhoden@bnflinc.com
Fri Oct 29 14:39:00 GMT 1999


fortran bug guru,

It appears that the file positioning gets screwed up when initiating a
backspace command followed by an endfile command.  This is for
gcc-2.95.1 running on Mandrake linux 6.0.  Attached is a bit of code
that recreates the problem.

This code when compiled with g77 -o testit test.f gives the following
errors to xterm:

fmt: end of file
apparent state: unit 9 named ./test.txt
last format: (A80)
lately reading sequential formatted external IO
Aborted (core dumped)


The problem does not show itself on either the backspace nor the endfile
command but rather after rewinding and then trying to reread the file.
However, by themselves niether of these commands causes the same error.
If you look at the attached file you'll note two commented lines.  If
you uncomment these read statements and comment out the backspace and
endfile statements,  you get the same error.  This of course is caused
by trying to read past the end of file.  I believe this means that the
combination of the backspace and endfile statements essentially get the
file position 'stuck' at the end of file so that no further file
positioning statements work and when the read statement is hit....

What I am trying to do is essentially eliminate the last record in a
file by backspacing to the beginning of the record and placing an end of
file termininator.  Any easy work around?

Thanks for any help and hopes this was useful.

Guy Rhoden




More information about the Gcc-bugs mailing list