[fpc-pascal] Range checks

Sven Barth pascaldragon at googlemail.com
Sat Jan 27 16:59:26 CET 2018

On 27.01.2018 15:10, C Western wrote:
> The following innocuous looking code generates a range check error:
> {$R+}
> function Count: qword;
> begin
>   Result := 0;
> end;
> var
>   i: Integer;
> begin
>   for i := 0 to Count-1 do
>     WriteLn(i);
> end.
> I can (more or less) see why, but it means that I can't (for example)
> compile the Cocoa widget set in 64 bit with bounds checking on, as then
> qword seems to be used as a count for, for example, NSarray.
> Am I missing something?

Integer is 32-bit, QWord is 64-bit. *Of course* there is a range check
error then. You need to use e.g. SizeInt as counter variable type in
those cases (SizeInt is 32-bit on 32-bit systems and 64-bit on 64-bit


More information about the fpc-pascal mailing list