[fpc-devel] large constant and qword comparison broken in fixes_2_4 rev 15403
Jonas Maebe
jonas.maebe at elis.ugent.be
Thu Jun 10 20:20:31 CEST 2010
On 10 Jun 2010, at 20:06, Seth Grover wrote:
> A recent change to fixes_2_4 (I think it was rev 15403) has broken
> this example. With yesterday's code the code prints out "same" both
> times (which is correct), but after pulling today's revision it only
> works if the constant is cast as a qword (it fails in the first
> example, works in the second). It should work correctly whether I cast
> the constant or not.
I'm not sure about that. The reason it doesn't work is because
a) $AB09CD87EF653412 is interpreted as an int64 constant (this was already the case before the change)
b) int64($AB09CD87EF653412) < 0
c) hence, qwordvar = $AB09CD87EF653412 can never be true.
The code also refuses to compile with range checking enabled (and prints a warning without range checking on).
It's the same situation as this code:
var
c: cardinal;
begin
c:=high(cardinal);
if c=-1 then
writeln('c = -1')
else
writeln('c <> -1');
end.
This prints, also with FPC 2.4.0, "c <> -1".
Jonas
More information about the fpc-devel
mailing list