[fpc-devel]RangeChecking & NOT operator
Paul Yanchenko
pusher at mailru.com
Wed Apr 10 12:47:50 CEST 2002
Good day for you, Florian!
Wednesday, April 10, 2002, 4:18:44 PM, you wrote:
>>Runtime error 201 at line 5
>>But that's not the behavior I would have expected.
>>I think this is a bug.
FK> Hmmm, not really. FPC does all evalutation of ordinal expressions with the
FK> natural integer size of the CPU thus everything is evaluted as 32 Bit =>
FK> NOT b eavlutes to $ffffffff which doesn't fit into a byte.
FK> This behavior is different to good old TP but it is conform with ANSI-Pascal
FK> standard. I did this decision 9 years ago when a started FPC, maybe it was
FK> wrong but in a lot of cases it makes the expression evalution more logical.
I don't think so. I think the result of operator should have same type
as an argument of operator. If we need different type - we shall use
type modifier ( not longint(b) ). Maybe exception is the case when
specified const value, i.e. for example (not 0) - there result type is
undefined.
BTW, what if we using type bigger than integer size of the CPU? I
tested this and
var
qw:qword;
begin
qw:=0;
writeln(not qw);
end.
In 1.0.4 program just written me character "/". Why it so - I don't
know. But 1.0.5 report me result that more similar to true:
18446744073709551615.
Anyway, in the snapshot (at least 1.0.5 [2001/12/16] for i386) it
seemes to work exactly as I offer. Just don't change anything! ;-)
-- Someone who loves to program and enjoys being clever about it
More information about the fpc-devel
mailing list