[fpc-pascal] Range checks

Dmitry Boyarintsev skalogryz.lists at gmail.com
Sat Jan 27 16:56:59 CET 2018


On Sat, Jan 27, 2018 at 10:06 AM, Adriaan van Os <fpc at microbizz.nl> wrote:
>
>
> The code shouldn't generate a range check error, as the target type is
> signed.
>

Count returns Unsigned Qword.
unsigned $FFFFFFFFFFFFFFFF is beyond 32-bit boundary.

The similar issue, but more explicit.

{$R+}
function Count: qword;
begin
  Result := 0;
end;

var
  i: Integer;
  K : Qword;
begin
  K:=count-1;
  writeln(K);
  I:=k;  // <-- rangecheck error
  writeln(i);
end.

thanks,
Dmitry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20180127/82939f8b/attachment.html>


More information about the fpc-pascal mailing list