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

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to