Robert wrote:I am trying to write a loop that can go up to MAX (LONGINT).
I understand why the simple way to write a FOR loop does not work, so am trying to write a custom WHILE loop.
I noticed that the following code TRAPs; is this a bug?
The special situation here is that LONGINT is treated in different ways by the compiler.
INC(a) is compiled into a pair of integer operations (add + add with carry) to form a 64 bit addition
out of two 32-bit operations.
In an expression like "a + 1" the compiler uses the FPU for 64 bit integer operations because, I guess, it uses
less registers and it is also applicable to other operations such as * and DIV.
The observable difference is in the handling of LONGINT overflows, which lead to a TRAP in case of
assigning an overflowed FPU register to an integer variable.
This behavior is described in the docu "Platform-Specific Issues (Windows)" under point 12.