[fpc-pascal] Division by Zero: EDivByZero and EZeroDivide
Bart
bartjunk64 at gmail.com
Tue Oct 20 11:54:16 CEST 2009
Jonas,
> In theory this is of course possible, but in practice this is extremely
> error prone due to the nature of signal handlers. Furthermore, adding extra
> global variables to the interface of the system unit is very much frowned
> upon, and this would be required since the signal handling happens in the
> system unit and the translation to exceptions in the sysutils unit.
I think this is how it's done in Delphi though.
> Another,
> and much easier, option would be to change the run time error number for
> either integer or floating point div-by-zero. But that would obviously cause
> its own share of compatibility problems.
Yes, a different runtime error is also not Delphi compatible ;-(
(But probably not likely te be relied on in existing code?)
One other thought. In the code that translates the signal to a
runerror, could we pass the signal info as an extra, optional
parameter to the runerror procedure, or would that also be "invisible"
to the sysutils unit, when intercepting runerrors?
If we cannot reliably differentiate in the signal handler between
integer divide by zero and floating point divide by zero, then we'd
better not try to fix it. Better be reliably inconsistent with delphi
than not being able to rely on what exception is raised.
In that case we should probably document this behaviour somewhere?
Bart
More information about the fpc-pascal
mailing list