RunError(215) occurs only in win 64 bit, not win 32 bit

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

RunError(215) occurs only in win 64 bit, not win 32 bit

Dennis
When I compiled the following simply programs using Lazarus 1.8  fpc
3.0.4 Win 64, run it, it will throws RunError(215) Arithmetic overflow
error.

However, if I compile and run the same in Lazarus 1.8 fpc 3.0.4 win 32,
it won't raise the RunError (215).
Why???


program test64bit;
{$mode objfpc}{$H+}
{$OVERFLOWCHECKS ON}
var
   LW1, LW2 : array[false..true] of LongWord;
   c : currency;
   aBoolean : Boolean;
begin
   LW1[false] := 5;
   LW1[true] := 5;

   LW2[false] := 10;
   LW2[true] := 10;
   c := 10;
   aBoolean :=  (LW1[true] + LW1[false]) - (LW2[false]+LW2[true]) > c ;
   Writeln('if compiled in 64 bit, a RunError(215) will have occurred
and it will not reach this line');
   readln;
end.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: RunError(215) occurs only in win 64 bit, not win 32 bit

Marco van de Voort
In our previous episode, Dennis said:
> When I compiled the following simply programs using Lazarus 1.8  fpc
> 3.0.4 Win 64, run it, it will throws RunError(215) Arithmetic overflow
> error.

Which seems correct. The expression to compare with is entirely longword and
it gets negative (5+5) - (10+10).

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: RunError(215) occurs only in win 64 bit, not win 32 bit

Bart-48
On Wed, Jan 24, 2018 at 12:59 PM, Marco van de Voort <[hidden email]> wrote:

> Which seems correct. The expression to compare with is entirely longword and
> it gets negative (5+5) - (10+10).

But shouldn't it then also give the same error if compiled for 32 bit?

Bart
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: RunError(215) occurs only in win 64 bit, not win 32 bit

Dennis


Bart wrote:
> On Wed, Jan 24, 2018 at 12:59 PM, Marco van de Voort <[hidden email]> wrote:
>
>> Which seems correct. The expression to compare with is entirely longword and
>> it gets negative (5+5) - (10+10).
> But shouldn't it then also give the same error if compiled for 32 bit?

Agree.

The weird thing is, in 32 bit, the compiler gives the  Hint: (4079)
Converting the operands to "Int64" before doing the add could prevent
overflow errors.
but does not raise the RunError(215).

The 64 bit compiler does not give the Hint but raises the RunError(215).

I think both versions should be fixed.

Dennis
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal