Floating-Point Exception: Stack Fault

From RAD Studio
Jump to: navigation, search

Go Up to Floating-Point Exceptions


The floating-point stack has been overrun. This error may be due to assembly code using too many registers or due to a misdeclaration of a floating-point function.

Example (for illustrative purposes):

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  I: Integer;
  S: Single;

begin
  try
    // FLD instruction loads a real value into the FPU stack
    for I := 0 to 32 do
    begin
      asm
        FLD S
      end;
    end;

  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;

end.

These floating-point errors can be avoided by setting the FPU control word. See the SetExceptionMask procedure:

    SetExceptionMask([exInvalidOp]);