Skip to content
GitLab
    • Why GitLab
    • Pricing
    • Contact Sales
    • Explore
  • Why GitLab
  • Pricing
  • Contact Sales
  • Explore
  • Sign in
  • Get free trial
  • FPC
  • FPC FPC
  • FPC SourceFPC Source
  • Issues
  • #37468

floating point exception not cleared

Original Reporter info from Mantis: BeniBela @benibela
  • Reporter name: Benito van der Zander

Description:

The floating point exception not cleared, when a Pascal exception is raised

Steps to reproduce:

In 3.0.4 this prints +Inf, in 3.3.1 it gives EDivByZero: Division by zero

program Project1;

{$mode objfpc}{$H+}

uses
  math, sysutils;
var
  a,b: double;
begin
  a := 0;
  b := -3;
  try
    writeln(power(a,b));
  except
    on e: EDivByZero do begin
      writeln(Infinity);
    end;
  end;
end.

Additional information:

This works:

In 3.0.4 this prints +Inf, in 3.3.1 it gives EDivByZero: Division by zero

program Project1;

{$mode objfpc}{$H+}

uses
  math, sysutils;
var
  a,b: double;
begin
  a := 0;
  b := -3;
  try
    writeln(power(a,b));
  except
    on e: EDivByZero do begin
      ClearExceptions(false);                            
      writeln(Infinity);
    end;
  end;
end.

This does not:

program Project1;

{$mode objfpc}{$H+}

uses
  math, sysutils;
var
  a,b: double;
begin
  a := 0;
  b := -3;
  try
    writeln(power(a,b));
  except
    on e: EDivByZero do begin
      try
        ClearExceptions(true);
      except
      end;
      writeln(Infinity);
    end;
  end;
end.

Mantis conversion info:

  • Mantis ID: 37468
  • OS: linux
  • OS Build: opensuse
  • Build: r45986
  • Platform: amd64
  • Version: 3.3.1
  • Fixed in version: 3.3.1
  • Fixed in revision: 46992 (#1a2b99bc)
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking