View Issue Details

IDProjectCategoryView StatusLast Update
0035136FPCRTLpublic2020-08-11 17:52
Reporterhelbig1 Assigned ToFlorian  
Status resolvedResolutionfixed 
Platformx86_64OSOS X 
Product Version3.0.4 
Fixed in Version3.3.1 
Summary0035136: The function EOF does not comply to ISO Pascal
DescriptionEOF returns true even before the file pointer passes the end of file.
Steps To ReproduceTurn on the ISO mode, compile and run the following program:
program p;
var f: text;
    f^ := 'a';
    if eof(f) then writeln('premature eof');
    if eof(f) then writeln('premature eof');
    if eof(f) then writeln('premature eof');
    if eof(f) then writeln('eof correctly set') else writeln('eof should be set, but isn''t');
Additional InformationWith this error is a show stopper, if you want to use ISO-Pascal.
TagsNo tags attached.
Fixed in Revision43801
Attached Files


Thaddy de Koning

2019-02-22 18:02

reporter   ~0114348

Last edited: 2019-02-22 18:11

View 3 revisions

This is fixed in 3.2.0.
I do not think your code is ISO compliant and contains errors. I miss input and output parameters for one...


2019-02-23 20:56

reporter   ~0114375

Nice to know, that this bug is fixed in 3.2.0.

Thaddy de Koning, you are right, the example program is not ISO compliant. It should list the output parameter, because later I used it when calling the writeln procedure. The program header should read:

program p(output);

With this fix the program is ISO compliant, isn't it?

Marco van de Voort

2019-02-24 15:30

manager   ~0114384

In normal FPC "text" files are writeonly. (only typed and untyped files are read/write)

What does ISO say about that R/W status of "text" files?


2019-02-25 13:56

reporter   ~0114404

Last edited: 2019-03-01 15:06

View 2 revisions

Textfiles are both readable and writeable, like any other file. All external files have to be listed as parameters in the program header and declared as variables, with the two exceptions "input" and "output". If they occur in the parameter list, they are implicitly declared as textfiles. When the input file is used for the first time, it is automatically opened for reading and when output is used for the first time, it is opened for writing. By the way, this works fine with FPC.

Marco van de Voort

2019-02-25 14:28

manager   ~0114409

I think I misread your example, doing put and get after a rewrite. I read over the reset() inbetween.


2019-02-25 15:02

reporter   ~0114410

The procedures get and put and the function eof refer to the internal text file f and writeln refers to the external file output.


2019-12-28 11:36

administrator   ~0120099

I am not sure, if the approach I have chosen is correct. If it does not work as expected, please provide more tests.


2020-07-23 18:31

reporter   ~0124281

The eof function works fine with release 3.2.0. The above program does not report premature eof. But get(f) throws runtime error 100 (reading past end of file), which it shouldn't.


2020-07-24 22:06

administrator   ~0124310

What's the expected result when reading past eof with get? Or do you get an premature rte 100 with get?


2020-08-04 15:53

reporter   ~0124545

According to the standard you can safely invoke get(f) as long as eof(f) is false. But f^ will be undefined after the last successful get(f).
Here is an example run that shows the FPC-Error:
$ cat eof.p
program p;
var f: file of char;
    f^ := 'a';
    while not eof(f) do
    writeln(f^); get(f)
    {at this point, f^ is undefined}
$ fpc eof.p
$ eof
Runtime error 100 at $0000000109BDD479


According to ISO-Pascal, the runtime error shouldn't be reported.

Issue History

Date Modified Username Field Change
2019-02-22 14:48 helbig1 New Issue
2019-02-22 18:02 Thaddy de Koning Note Added: 0114348
2019-02-22 18:10 Thaddy de Koning Note Edited: 0114348 View Revisions
2019-02-22 18:11 Thaddy de Koning Note Edited: 0114348 View Revisions
2019-02-23 20:56 helbig1 Note Added: 0114375
2019-02-24 15:30 Marco van de Voort Note Added: 0114384
2019-02-25 13:56 helbig1 Note Added: 0114404
2019-02-25 14:28 Marco van de Voort Note Added: 0114409
2019-02-25 15:02 helbig Note Added: 0114410
2019-03-01 15:06 helbig1 Note Edited: 0114404 View Revisions
2019-12-28 11:36 Florian Assigned To => Florian
2019-12-28 11:36 Florian Status new => resolved
2019-12-28 11:36 Florian Resolution open => fixed
2019-12-28 11:36 Florian Fixed in Version => 3.3.1
2019-12-28 11:36 Florian Fixed in Revision => 43801
2019-12-28 11:36 Florian FPCTarget => -
2019-12-28 11:36 Florian Note Added: 0120099
2020-07-23 18:31 helbig Note Added: 0124281
2020-07-24 22:06 Florian Note Added: 0124310
2020-08-04 15:53 helbig Note Added: 0124545