[fpc-devel]RangeChecking & NOT operator

Florian Klaempfl Florian.Klaempfl at gmx.de
Wed Apr 10 12:18:44 CEST 2002


At 10:10 10.04.02 +0200, you wrote:
>compiler: FPC 1.0.4
>target:   go32v2
>
>
>1:   var
>2:      b: byte;
>3:   begin
>4:   b := 0;
>5:   b := NOT b;
>6:   end.
>
>
>Switch range checking ON compile and run.
>You will get:
>
>Runtime error 201 at line 5
>
>But that's not the behavior I would have expected.
>I think this is a bug.

Hmmm, not really. FPC does all evalutation of ordinal expressions with the
natural integer size of the CPU thus everything is evaluted as 32 Bit =>
NOT b eavlutes to $ffffffff which doesn't fit into a byte.

This behavior is different to good old TP but it is conform with ANSI-Pascal
standard. I did this decision 9 years ago when a started FPC, maybe it was 
wrong but
in a lot of cases it makes the expression evalution more logical.





More information about the fpc-devel mailing list