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

Gerhard Scholz gs at g--s.de
Fri Jul 8 20:34:19 CEST 2005


----- Original Message -----
From: "Peter Vreman" <peter at freepascal.org>
To: "FPC developers' list" <fpc-devel at lists.freepascal.org>
Sent: Friday, July 08, 2005 6:31 PM
Subject: Re: [fpc-devel] bug: Inc(v,i)/Dec(v,i)


> >>   v:=v+-5;
> >
> > I'm sorry, v IS unsigned, delta IS signed, and the computation has to be
> > done. Besides, v and d are 8-bit or 16-bit, and the result WILL fit in v
> > (that is checked before for other reasons).
>
> Range check errors are inserted only at assignment. Within the expression
> at the right side the value can be bigger/smaller than what is allowed.
> The compiler even doesn't know the type of the final destination at that
> time. And in pascal the rule is to do the calculations in the native
> integer type. That means 32 bit (or 64 bit for amd64).

inc ( v, d ) gives an overflow, not a rangecheck, when v is unsigned and i
is signed.

V is byte or word, D is shortint or smallint, the result is positive and in
the range of V, and the whole thing produces an overflow, that's the
problem.





More information about the fpc-devel mailing list