[fpc-pascal] Division by Zero: EDivByZero and EZeroDivide

Jonas Maebe jonas.maebe at elis.ugent.be
Tue Oct 20 09:49:57 CEST 2009


On 19 Oct 2009, at 19:08, Bart wrote:

> In the code that "translates" the "you did something nasty" to
> runerror(some_exit_code) it may be possible to differentiate between
> float and integer fault?

It is (on some platforms with some hacking).

> This info could then be stored in some variable/object that can be
> used by the code that intercepts the run-time error and raises the
> actual fpc exception?

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. 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.


Jonas



More information about the fpc-pascal mailing list