[fpc-pascal] Division by Zero - not raised exception

Sasa Zeman public at szutils.net
Sun Apr 16 16:38:33 CEST 2006

> The program won't compile with -Cr.

Program with -Cr will compile and link if all is correct. Eventually range
check error compiler can predict, will stop compilation as usually.
Otherwise, program itself will check range on each attemp to work with
arrays or calculations, which is clearly waste of time.

> ... operating system or CPU ...
> but not the compiler ;)

"... As well globaly, in consistency terms." I can not see reasonability of
different threaded division by zero by CPU/FPU or compiler. Delphi have
several inconveniently basically solved problems, among of which is this
one. Handling by inheritance Delphi solution in FPC mode is unfortunate.

> The point is: this div by zero is encountered at compilation time.
> The other option is to stop compilation always. Executing the operation
> at run time is useless imo and a waste of CPU cycles.
> No. These constants are defined in const blocks. A const block couldn't
> throw an exception.

Even better. In compilation time, if compiler detect division by zero with
constants it should stop compilation - by default, without any switch. I can
not see reason to be threaded differently.

In that case there is no problems: 'Writeln (1.0/0.0)' or 'a:=a*b+1/0' and
similar constructions should be threaded by default. It is mathematical
nosence continuing calculating ratinals - during complex calculations,
simple error will lead to infinity result instead to simply stop during
compilation and show the error.

I see no problem in implementation.

More information about the fpc-pascal mailing list