View Issue Details

IDProjectCategoryView StatusLast Update
0037468FPCRTLpublic2020-08-10 15:34
ReporterBenito van der Zander Assigned ToFlorian  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platformamd64OSlinux 
Product Version3.3.1 
Fixed in Version3.3.1 
Summary0037468: floating point exception not cleared
DescriptionThe floating point exception not cleared, when a Pascal exception is raised
Steps To ReproduceIn 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 InformationThis 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.

TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget-
Attached Files

Activities

Benito van der Zander

2020-08-02 16:24

reporter   ~0124506

Also this:

program Project1;

{$mode objfpc}{$H+}

uses math, sysutils
  { you can add units after this };

begin
  try
    writeln(power(0, -4));
  except
    on e: EDivByZero do ClearExceptions(false);
  end;
  try
    writeln(power(0, -3));
  except
    on e: EDivByZero do ClearExceptions(false);
  end;
  try
    writeln(power(0, -4));
  except
    on e: EDivByZero do ClearExceptions(false);
  end;

  writeln(power(16, 0.5));
end.

prints "EInvalidOp: Invalid floating point operation" on power(16, 0.5)

Is the FPU stack corrupted?

Florian

2020-08-10 15:34

administrator   ~0124732

Fixed meanwhile, the right exception type is EZeroDivide (float). EDivByZero is for ints.

Issue History

Date Modified Username Field Change
2020-08-02 15:59 Benito van der Zander New Issue
2020-08-02 16:24 Benito van der Zander Note Added: 0124506
2020-08-10 15:34 Florian Assigned To => Florian
2020-08-10 15:34 Florian Status new => resolved
2020-08-10 15:34 Florian Resolution open => fixed
2020-08-10 15:34 Florian Fixed in Version => 3.3.1
2020-08-10 15:34 Florian FPCTarget => -
2020-08-10 15:34 Florian Note Added: 0124732