[fpc-devel] Overflow checks and Trunc/Round functions

Florian Klaempfl florian at freepascal.org
Sat Jun 13 13:45:32 CEST 2009


Alexander Klenin schrieb:
> Currently, Round and Trunc functions ignore the state of $OVERFLOWCHECKS
> compiler directive. The following code prints "-2 -2":
> 
> {$MODE OBJFPC}{$OVERFLOWCHECKS ON}
> var
>   a: Integer;
>   b: Double;
> begin
>   b := MaxInt;
>   a := Round(2.0 * b);
>   Writeln(a);
>   a := Trunc(2.0 * b);
>   Writeln(a);
> end.
> 
> This is Delphi-compatible.
> However, I think this is a bug, even if Delphi-inherited, and should
> be fixed in fpc/objfpc mode.
> What do others think?
> 

Which arithemtic operation overflows? Fill a bug report, if you no range
check error is thrown.



More information about the fpc-devel mailing list