[fpc-pascal]QWORD error ?

Jonas Maebe jonas.maebe at elis.ugent.be
Mon Apr 5 13:31:07 CEST 2004


On 5 apr 2004, at 12:12, Lubomir.Cabla at cssz.cz wrote:

>   L:=-1;
>   qw:=qw+(-L);                { qw=99 O.K. }
> (*
>   qw:=qw-L;                   { run time error 201 }
>   qw:=qw+L;                   { run time error 201 }
> *)
[snip]
> Could somebody help me what's wrong ?

The problem is that the compiler has to convert both operands to the 
same type when you do an operation. When you are working with the 
largest supported unsigned type (qword currently), this means that both 
operands are first converted to qword. -1 is an invalid value for a 
qword, so you get a range check error.

That's also the reason why Turbo Pascal only supported longint, and not 
cardinal: it breaks range checking.


Jonas





More information about the fpc-pascal mailing list