IOResult documentation not clear enough
Original Reporter info from Mantis: Thaddy
-
Reporter name: Thaddy de Koning
Original Reporter info from Mantis: Thaddy
- Reporter name: Thaddy de Koning
Description:
In {$I-} it should be noted that all IO operations are ignored until IOResult is read. This can be really confusing, so a little extra remark should be in place.
Steps to reproduce:
Consider:
program File_assign;
{$mode objfpc}{$H+}
uses
CRT, sysutils;
var
FileX: text;
X: double;
begin
try
{$I-}
assign(FileX,'FileX1');
close(FileX);
{$I+}
// if IoResult <> 0 then writeln('Failed');
finally
begin
writeln('End of program. ');
readkey;
end;
end;
end.
In this case, because IO operations are ignored, it seems like the finally block is never executed since writeln and readkey are IO operations.
When you remove the comment, so IOResult is read, you will get the begavior as expected.
Additional information:
See http://forum.lazarus.freepascal.org/index.php/topic,35115.msg231678.html#msg231678
Mantis conversion info:
- Mantis ID: 31113
- OS: all
- OS Build: all
- Build: 35112
- Platform: all
- Version: 3.1.1
- Fixed in version: 3.1.1
- Fixed in revision: 1375 (#ded07112)
- Target version: 3.2.0