[fpc-devel] bug: Inc(v,i)/Dec(v,i)
Gerhard Scholz
gs at g--s.de
Tue Jul 5 13:53:46 CEST 2005
...
> Bug 4152 is partly fixed. The compiletime error is removed. Only the
> runtime overflow is left. That still needs to be decided how to handle it.
> The following code also fails with an overflow
>
> {$Q+}
> var
> v : cardinal;
> begin
> v:=100;
> inc(v,-1);
> end.
>
> The reason is that -1 is in fact an addition of $ffffffff resulting in the
> carry flag being set and therefor an overflow.
Maybe the cleanest way is (in the $r+ $q+ mode) to handle
inc ( v, d ) ;
the same as
v := v + d ;
I replaced my code like this when I found the bug, and now my code works.
Gerhard
More information about the fpc-devel
mailing list