[fpc-devel] bug: Inc(v,i)/Dec(v,i)
C Western
mftq75 at dsl.pipex.com
Wed Jul 6 22:25:33 CEST 2005
Marco van de Voort wrote:
>>>>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.
>>>
>>>For cardinal IMHO not-a-bug?
>>
>>I think it's a bug for cardinals and other unsigned ints also (as long as the
>>result is in the range of the result variable)
>
>
> -1 is not a valid cardinal -> out of range -> rangecheck error.
>
But on the other hand Dec(v,1) is fine, so Inc(v,-1) should also work.
Colin
More information about the fpc-devel
mailing list