[fpc-devel] Exception handling differences with Delphi

Florian Klämpfl florian at freepascal.org
Thu Nov 24 19:48:18 CET 2011


Am 24.11.2011 14:59, schrieb Sergei Gorelkin:
> Hello,
> 
> There are some differences between FPC and Delphi exception handling
> (working on SEH support, one would inevitably collect all of them):
> 
> 1) Delphi uses EZeroDivide for floating-point division by zero, while
> FPC uses EDivByZero (the same exception class is used for integer
> division by zero). Should it be fixed?

At least a distinction should be made.

> 
> 2) Delphi uses EUnderflow for floating-point underflow condition, while
> FPC uses EOverflow. Should it be fixed?

Same here.

> 
> 3) Delphi halts in ExceptProc, while in FPC ExceptProc only prints the
> exception information and then returns. I don't imagine why someone
> would call ExceptProc from the user code, still, is this worth fixing?

IMO no.

> 
> 4) Delphi resets FPU on every exception, while FPC does it only for
> FPU-related exceptions. Do we really need to be different in this respect?

Is there a need to reset it at every exception?

> 
> 5) What is the 'Athlon prefetch bug' we're trying to handle? Should be
> an old thing, since it originates from svn revision 1; googling for
> 'Athlon prefetch bug' does not give relevant information, and my general
> knowledge tells that such code should normally reside in OS kernel, not
> in RTL. Anyway, does it apply to x86_64 target?

Some old athlons, might include x86_64 ones, had a bug that sometimes
prefetch (0^) causes a sig fault while it shouldn't, prefetch(0^)
happens in the typical use case of prefetch:

while assigned(p) do
  begin
    prefetch(p^.next^);
    ...
    ...
    p:=p^.next;
  end;



More information about the fpc-devel mailing list