[fpc-devel]RangeChecking & NOT operator

Peter Beisel beisel at kbprueftechnik.frm.de
Wed Apr 10 15:33:44 CEST 2002


But the other logical operators (AND, OR, XOR ... ) don't have this problem.
No one of them causes a range check error when used on byte-variables and
range checking is active.

Regards Peter

Florian Klaempfl schrieb:

> 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.
>
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel





More information about the fpc-devel mailing list