View Issue Details

IDProjectCategoryView StatusLast Update
0037398FPCCompilerpublic2020-07-23 10:15
ReporterBenito van der Zander Assigned ToFlorian  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platformamd64OSlinux 
Product Version3.3.1 
Fixed in Version3.3.1 
Summary0037398: branchless float comparison triggers SIGFPE on NaN
DescriptionBoolean operations with float are not short-circuit evaluated anymore
Steps To Reproduceprogram testnan;

{$mode objfpc}{$H+}

uses math;
var d: double;
  temp: Boolean;
begin
  d := NaN;
  temp := IsNan(d) or (d = 0);
  writeln(temp);
end.
              

prints TRUE on 3.0.4 and makes a SIGFPE on 3.3.1
Additional InformationProgram received signal SIGFPE, Arithmetic exception.
0x00000000004010cc in main () at testnan.lpr:10
10 temp := IsNan(d) or (d = 0);
...
   0x0000000000401096 <+6>: lea 0x5ff63(%rip),%rax # 0x461000
   0x000000000040109d <+13>: lea 0x8734c(%rip),%rdx # 0x4883f0 <U_$P$TESTNAN_$$_D>
   0x00000000004010a4 <+20>: mov (%rax),%rax
   0x00000000004010a7 <+23>: mov %rax,(%rdx)
   0x00000000004010aa <+26>: lea 0x8733f(%rip),%rax # 0x4883f0 <U_$P$TESTNAN_$$_D>
   0x00000000004010b1 <+33>: movsd (%rax),%xmm0
   0x00000000004010b5 <+37>: callq 0x429d80 <MATH_$$_ISNAN$DOUBLE$$BOOLEAN>
   0x00000000004010ba <+42>: lea 0x5ff47(%rip),%rdx # 0x461008
   0x00000000004010c1 <+49>: movsd (%rdx),%xmm0
   0x00000000004010c5 <+53>: lea 0x87324(%rip),%rdx # 0x4883f0 <U_$P$TESTNAN_$$_D>
=> 0x00000000004010cc <+60>: comisd (%rdx),%xmm0
   0x00000000004010d0 <+64>: setnp %dl
   0x00000000004010d3 <+67>: sete %cl
   0x00000000004010d6 <+70>: and %dl,%cl
   0x00000000004010d8 <+72>: or %cl,%al
   0x00000000004010da <+74>: lea 0x8731f(%rip),%rdx # 0x488400 <U_$P$TESTNAN_$$_TEMP>
TagsNo tags attached.
Fixed in Revision45824
FPCOldBugId
FPCTarget-
Attached Files

Activities

Thaddy de Koning

2020-07-23 10:14

reporter   ~0124254

Last edited: 2020-07-23 10:15

View 2 revisions

Ok. but assigning NaN should never be valid.
IOW that behavior should be expected.

Issue History

Date Modified Username Field Change
2020-07-21 16:00 Benito van der Zander New Issue
2020-07-21 22:09 Florian Assigned To => Florian
2020-07-21 22:09 Florian Status new => resolved
2020-07-21 22:09 Florian Resolution open => fixed
2020-07-21 22:09 Florian Fixed in Version => 3.3.1
2020-07-21 22:09 Florian Fixed in Revision => 45824
2020-07-21 22:09 Florian FPCTarget => -
2020-07-23 10:14 Thaddy de Koning Note Added: 0124254
2020-07-23 10:15 Thaddy de Koning Note Edited: 0124254 View Revisions