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

Sven Barth pascaldragon at googlemail.com
Thu Dec 10 07:34:27 CET 2020


Am 09.12.2020 um 23:45 schrieb Bart via fpc-devel:
> Compiled with fpc 3.2.0 on Windows it will output (both 32 and 64 bit):
> Runtime error 201 at $004015F1
>    $004015F1
>    $00407307
>
> Compiled with fpc 3.2.0 on linux X86_64 it will output
> Except block
> Finally block
>
> On Windows you need to include the sysutils unit to execute the except
> and finally block.

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.

> Note 1:  fpc 3.0.4 on Windows generates the same outpus as 3.2.0 on Linux...
> Note 2: Delphi 7 behaves like 3.2.0

Behaves like 3.2.0 on what platform? I assume Windows, cause Delphi 10.2 
behaves the same as FPC 3.2.0 on Windows.

> Is there any explanation for that?
> Related forum discussion:
> https://forum.lazarus.freepascal.org/index.php/topic,52469.0/topicseen.html
It's possibly related to FPC using SEH on Win32 and Win64 instead of the 
SetJump/LongJump based exception handling on other platforms. Slight 
differences are possible and we'd have to investigate why the later does 
not correctly trigger a runtime error.

Regards,
Sven


More information about the fpc-devel mailing list