Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2011-07

IO checks across packages

3 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Martin

I found a problem with IO checks, if a project is compiled using packages, that have been compiled with other settings. I wonder, if this would be considered a bug:

If some packages are compiled with and some without IO checking. An IO error happens in a package that is compiled without IO checking, as expected no error is risen here. But the error is stored, and an unrelated statement which has IO checks will fail later.

The following demo project enables and disables IO checks to simulate the situation.

program Project1;
{$mode objfpc}{$H+}
begin
   {$I+}
   writeln('1');
   {$I-}
   chdir('c:\IDoNotExist');
   {$I+}
   writeln('2');  // error for chdir is risen here
   readln;
end.

Reply by email

Jonas Maebe
to Martin
Martin wrote 15 lines
If some packages are compiled with and some without IO checking. An IO error happens in a package that is compiled without IO checking, as expected no error is risen here. But the error is stored, and an unrelated statement which has IO checks will fail later. The following demo project enables and disables IO checks to simulate the situation. program Project1; {$mode objfpc}{$H+} begin {$I+} writeln('1'); {$I-} chdir('c:\IDoNotExist'); {$I+} writeln('2'); // error for chdir is risen here readln; end.

That is normal. If you disable iochecks, you're supposed to call ioresult to check for errors (which will in turn reset any stored error conditions).

Jonas

Reply by email

Pete Cervasio
to Martin: I found a problem with IO checks, if a project is compiled using packages, that have been…
Martin wrote 11 lines
The following demo project enables and disables IO checks to simulate the situation. program Project1; {$mode objfpc}{$H+} begin {$I+} writeln('1'); {$I-} chdir('c:\IDoNotExist');

You have to check IOResult at this point, since you told the compiler not to do it for you. If you don't, then the error will propagate, as you've seen. This behavior has existed forever (since Turbo Pascal 3.0 at the least, maybe 2.0 had it as well).

Best regards,
Pete C.

Reply by email