[fpc-devel] Different handling of try..except depending on OS?

Sven Barth pascaldragon at googlemail.com
Thu Dec 10 13:47:07 CET 2020

Bart via fpc-devel <fpc-devel at lists.freepascal.org> schrieb am Do., 10.
Dez. 2020, 11:56:

> On Thu, Dec 10, 2020 at 7:34 AM Sven Barth via fpc-devel
> <fpc-devel at lists.freepascal.org> wrote:
> > That is correct, because without the SysUtils unit (which declared the
> > Exception type) the RTL can't convert the triggered runtime error to an
> > exception type that can be caught inside the try ... except ... end
> block.
> I would have expected that in that scenario (no sysutils) try..except
> or try..finally should raise a compilation error then.
> Since you teel the compiler to do things it cannot do?
> It would be Delphi incompatible of course ...

The *compiler* handles it correctly. It's the *RTL* that's not setup in a
way that it would work correctly in that case. And since in theory the user
is completely free to provide their own RTL the compiler can't do any
checks here.

> B.t.w. (cannot test now, am at work): does it catc exceptions if any
> other used unit in the main program uses sysutils?
> I.o.w.: is it enough if sysutils gets linked in, or must it be in the
> unit/prgram that actually has the try..except/try..finally code in it?

The initialization section of the SysUtils unit needs to be executed, so as
long as any other unit includes the SysUtils unit it will work.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20201210/13938e16/attachment.htm>

More information about the fpc-devel mailing list