Forum > Operating Systems
Inconsistency between Windows and Linux compiling?
Alex Kidd:
Blaazen, which Linux distro are you using?
It seems you and Zoran are experimenting different outputs. I tried also Mint 11, and still I get the +inf behaviour (with no exception).
I get the SIGFPE error too when using DIV instead of "/" (the exception is EInvalidOp, Invalid floating point operation). :D
Zoran, what disto / fpc version are you using by the way?
I think something strange is going on here... 8-)
Alex Kidd:
Well, maybe the title I used in the topic is incorrect. I think I found out the difference is not between the Linux and WinXP version, but between "Application" and "Program".
The application shows the +inf behaviour, while the program behaves like Zoran's test.
Here are the two codes:
APPLICATION
--- Code: ---unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
var
x,y:integer;
res:double;
begin
x:=5;
y:=0;
try
res:=x / y;
except on e:exception do
memo1.append(e.message);
end;
memo1.append(floattostr(res));
end;
end.
--- End code ---
PROGRAM
--- Code: ---program Project1;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes,sysutils
{ you can add units after this };
{$R *.res}
var
x,y:integer;
res:double;
begin
x:=5;
y:=0;
try
res:=x / y;
except on e:exception do
writeln(e.message);
end;
writeln(floattostr(res));
end.
--- End code ---
Later on I'm going to reboot to winxp and test if my theory is confirmed (i.e. I was really wrong suspecting Lin and Win compile differently... O:-)).
Alex Kidd:
Back on line.
I tested the two codes in WinXP and I always got the Divide By Zero exception.
My suspect is that in the Application version in Linux Mint 10 and 11 (and the distro used by Blazeen) the compiler somehow think 5/0 is a valid operation, and the risult is +inf.
Help!!! %)
Blaazen:
My first attempt was in Chakra (Arch-based linux). I rebooted to Kubuntu with the same result (Res:+Inf). (both are 64-bit)
Then I tried compile it without Lazarus from console (fpc filename.pas - without compiler options). I tried both as program and as unit - both gives Division by Zero.
So it is not distro related. It must be some special compiler option which Lazarus uses but I don't know which, they are so many.
Bart:
Might have something to do with the exceptionmask (unit math)?
Bart
Navigation
[0] Message Index
[#] Next page
[*] Previous page