View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0038506 | FPC | RTL | public | 2021-02-18 04:44 | 2021-02-24 11:12 |
Reporter | Juan Díaz | Assigned To | |||
Priority | normal | Severity | minor | Reproducibility | always |
Status | new | Resolution | open | ||
Platform | i386 | OS | Windows 7 | ||
Product Version | 3.2.0 | ||||
Summary | 0038506: Run-time error 100 is produced when an application applies the procedure GET to a binary file throughout | ||||
Description | When applying the procedure GET to files whose components are of file types other than text and end-of-file is reached, run-time error 100 is reported. After compiling the following source code and executing the program, the run-time error in question is produced. {$mode iso} program TestGetOnBinaryFiles(fr, output); {runtime error 100 is produced} const max = 100; type FileOfReal = file of real; var fr: FileOfReal; procedure createfileofreal(var fr: FileOfReal); var i: 1..max; r: real; begin writeln; assign(fr, 'RealNumbers.dat'); rewrite(fr); for i := 1 to max do begin r := i * 1.95; fr^ := r; put(fr) end ; close(fr) end ; procedure printfileofreal(var fr: FileOfReal); begin writeln; writeln('Contents of file:'); reset(fr); while not eof(fr) do begin writeln(fr^ :3:2); get(fr) end ; close(fr); writeln end ; begin createfileofreal(fr); printfileofreal(fr) end . However, when the file is of type text and the procedure GET is used to access all of its components, no run-time error occurs. {$mode iso} program TestGetOnTextfiles(f, output); {no run-time error is produced} var f: text; ch: char; begin writeln; writeln('Contents of file:'); writeln; assign(f, 'ATextfile.txt'); reset(f); while not eof(f) do begin ch := f^; write(ch); get(f) end ; close(f); writeln end . In my humble opinion, this issue should be fixed in order for FPC to comply with the ISO 7185 standard since the following example from page 31 of the ISO 7185 Pascal standard document also causes the aforementioned run-time error. procedure CopyFiles (var from, into : FileOfInteger); begin reset(from) ; rewrite(into); while not eof(from) do begin into^ := from^; put(into) ; get(from) end end { of CopyFiles }; | ||||
Steps To Reproduce | Compile the source code files attached and run the programs. | ||||
Tags | ISO 7185 Standard Pascal | ||||
Fixed in Revision | |||||
FPCOldBugId | |||||
FPCTarget | |||||
Attached Files |
|
|
TestGetOnBinaryFiles.pas (748 bytes)
{$mode iso} program TestGetOnBinaryFiles(fr, output); const max = 100; type FileOfReal = file of real; var fr: FileOfReal; procedure createfileofreal(var fr: FileOfReal); var i: 1..max; r: real; begin writeln; assign(fr, 'RealNumbers.dat'); rewrite(fr); for i := 1 to max do begin r := i * 1.95; fr^ := r; put(fr) end ; close(fr) end ; procedure printfileofreal(var fr: FileOfReal); begin writeln; writeln('Contents of file:'); reset(fr); while not eof(fr) do begin writeln(fr^ :3:2); get(fr) end ; close(fr); writeln end ; begin createfileofreal(fr); printfileofreal(fr) end . TestGetOnTextfiles.pas (345 bytes)
{$mode iso} program TestGetOnTextfiles(f, output); var f: text; ch: char; begin writeln; writeln('Contents of file:'); writeln; assign(f, 'ATextfile.txt'); reset(f); while not eof(f) do begin ch := f^; write(ch); get(f) end ; close(f); writeln end . |
|
Seems to run fine with fpc 3.3.1 r48092 on win32 and win64. |
Date Modified | Username | Field | Change |
---|---|---|---|
2021-02-18 04:44 | Juan Díaz | New Issue | |
2021-02-18 04:44 | Juan Díaz | File Added: TestGetOnBinaryFiles.pas | |
2021-02-18 04:44 | Juan Díaz | File Added: TestGetOnTextfiles.pas | |
2021-02-18 04:44 | Juan Díaz | File Added: ATextfile.txt | |
2021-02-22 18:57 | Juan Díaz | Tag Attached: ISO 7185 Standard Pascal | |
2021-02-24 11:12 | Bart Broersma | Note Added: 0129140 |