Forum > General

FPC uses st(0) and st(1) for addtion of floating point numbers

(1/1)

shiraishi_kazuo:
FPC uses st(0) and st(1) for addtion of floating point numbers.
But some LCL method seemes to destroy FPU registers.
For example, the following program  raises exception class 'External SIGFPE'.
Tested on Windows XP(32bit), using lazarus 0.9.28.2. 


interface

uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
  StdCtrls, SynEdit;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    SynEdit1: TSynEdit;
    procedure Button1Click(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;

implementation

{ TForm1 }
function f(x:double):double;
begin
  result:=x;
end;

function g(x:double):double;
begin
  result:=x;
  Form1.SynEdit1.seltext:='ABC';  // :'(This might destroy FPU registers
end;

procedure TForm1.Button1Click(Sender: TObject);
var
   x:double;
begin
   x:=f(1)+g(2);
end;

initialization
  {$I unit1.lrs}

end.
                                   

DougNettleton:
Not sure what "might" means in "// :'(This might destroy FPU registers".
 
Does it always happen?

Just tried with the following daily snapshot ...

Lazarus-0.9.29-27235-fpc-2.4.3-20100830-win32 on Win XP

Repeatedly pushing the button worked as expected, i.e. the SynEdit1 component was updated and no exception raised neither within the debugger nor when executed directly.

91% of the bug reports to 0.9.30 are complete so maybe a newer better release will be out soon.  Nearly 300 issues with 0.9.28.2 have been resolved.

Good luck.

Doug

Navigation

[0] Message Index

Go to full version