[fpc-pascal] Is this an error ?
Matthias K.
makadev at googlemail.com
Fri Oct 2 01:38:30 CEST 2009
Hi,
I compiled this with fpc -al .. under linux 64.
The difference is, "r := <integer> div <qword>" results in an "divq"
instruction wich is for unsigned integer division only. "r :=
<integer> div <int64>" results in "idivq" which is for signed integer
division.
On execution this results in an error (i've got divbyzero on amd64)
for the first one, which is a result of the signed/unsigned integer
conversion and division mix.
Short: Use int64 types for the signed division for quotient and divisor
On Mon, Sep 28, 2009 at 9:31 PM, JoshyFun <joshyfun at gmail.com> wrote:
> Hello FPC-Pascal,
>
> Can anybody explain me if this code is expected to fail with a SIGFPE
> in 64 bits windows 2.2.4 fpc:
>
> procedure test;
> var
> i6: int64;
> qw: QWord;
> r: int64;
> begin
> i6:=40;
> qw:=40;
> r:=(integer(-1)*i6) div qw;
> end;
>
> Replacing "qw" with an int64 runs fine.
>
> --
> Best regards,
> JoshyFun
>
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
More information about the fpc-pascal
mailing list