Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2018-01

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

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

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.

Reply by email

Marco van de Voort
to Dennis

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).

Reply by email

Dennis
to Bart
Bart wrote 5 lines
On Wed, Jan 24, 2018 at 12:59 PM, Marco van de Voort 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

Reply by email