[fpc-devel] Bug 4004

Hans-Peter Diettrich DrDiettrich at compuserve.de
Tue Jun 7 02:07:13 CEST 2005


Gerhard Scholz wrote:
> 
> The check for overflow is obviously implemented different in 2.0.0 and 2.1.1

I'm not sure, at least

> .L9:
>      movw %dx,-12(%ebp)
> .Ll3:

suggests that the target is not an integer, but instead is a (possibly
unsigned) word type. Please check again!

> A solution would be to replace that line by:
>     d := integer(Ord(a))-Ord(b)
> 
> It seems that the compiler now sees a "ord(c)" to be a BYTE, and BYTE - BYTE
> shall give a BYTE, and -1 is not in the range allowed for a BYTE.

Differences always should be interpreted as signed values, the error
message IMO comes from the final assignment.

> The line " i := Ord('0')-Ord('1') " in the main program is not interesting,
> since it contains a constant expression and is converted to " i := -1 " by
> the compiler.

Now you assume that the difference can exceed the range of Ord(char),
when computed at compile time? Or is it only the different type of the
target variable?

DoDi






More information about the fpc-devel mailing list