[fpc-devel] bug: Inc(v,i)/Dec(v,i)

Peter Vreman peter at freepascal.org
Thu Jul 7 07:39:32 CEST 2005

> shouldn't it implement inv(v,-1) in exactly the same way it implements
> v:=v-1?

The problem is what type do you give to -1. In the old situation the -1
was converted to the same type as v -> longword. Resulting in $ffffffff.
Adding the $ffffffff gives an overflow.

Note that the compiler doesn't know that -1 is a negative value. Because
it can also be a variable:


If you translate inc(v,-1) to v:=v+(-1) then the operation is done in
64bit mode. It is the only way to garauntee that there is no overflow but
still a rangecheck for the result value.

It should be solved now in the current svn trunk.

More information about the fpc-devel mailing list