-Miso mode reports EOF when not at true file end
Original Reporter info from Mantis: samiam95124
-
Reporter name: Scott Franco
Original Reporter info from Mantis: samiam95124
- Reporter name: Scott Franco
Description:
Using ISO 7185 mode switch -Miso, the run time system reports EOF when not at the end of the file. This was validated to be at read time and not write time by examining the temp file output.
Steps to reproduce:
The following test program illustrates the issue:
program test(output);
label 99;
type byte = 0..255;
var f: file of byte;
b: byte;
i: integer;
begin
rewrite(f);
for b := 1 to 10 do write(f, b);
reset(f);
for i := 1 to 10 do begin
if eof(f) then begin
writeln('End of file');
goto 99
end;
read(f, b);
write(b:1, ' ')
end;
99:
end.
C:\scratch>fpc -Miso test.pas
Free Pascal Compiler version 3.0.4 [2017/10/06] for i386
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling test.pas
Linking test.exe
30 lines compiled, 0.1 sec, 29712 bytes code, 1300 bytes data
C:\scratch>test
1 2 3 4 5 6 7 8 9 End of file
C:\scratch>od -t x1 fpc_2300F8CC.tmp
0000000 01 02 03 04 05 06 07 08 09 0a
0000012
IE, it reads 9 values from the file and then indicates EOF even though the file is not, in fact at EOF. In fact, if you comment out the EOF test in the code it works fine, so the EOF indication is apparently false.
I suspect this is an issue with file buffer handling (Lazy I/O).
Mantis conversion info:
- Mantis ID: 32938
- OS: Windows
- OS Build: 10
- Platform: FPC
- Version: 3.0.4
- Fixed in version: 3.1.1
- Fixed in revision: 37915 (#273045c2)