Pārlūkot izejas kodu

* float operations can have an exception as a side effect, resolves #37398

git-svn-id: trunk@45824 -
florian 5 gadi atpakaļ
vecāks
revīzija
5da913de0e
3 mainītis faili ar 16 papildinājumiem un 1 dzēšanām
  1. 1 0
      .gitattributes
  2. 3 1
      compiler/nutils.pas
  3. 12 0
      tests/webtbs/tw37398.pp

+ 1 - 0
.gitattributes

@@ -18382,6 +18382,7 @@ tests/webtbs/tw37323.pp svneol=native#text/pascal
 tests/webtbs/tw37339.pp svneol=native#text/pascal
 tests/webtbs/tw37393.pp svneol=native#text/pascal
 tests/webtbs/tw37397.pp svneol=native#text/plain
+tests/webtbs/tw37398.pp svneol=native#text/pascal
 tests/webtbs/tw3742.pp svneol=native#text/plain
 tests/webtbs/tw3751.pp svneol=native#text/plain
 tests/webtbs/tw3758.pp svneol=native#text/plain

+ 3 - 1
compiler/nutils.pas

@@ -1427,7 +1427,9 @@ implementation
            ((mhs_exceptions in pmhs_flags(arg)^) and
             ((n.nodetype in [derefn,vecn,divn,slashn]) or
              ((n.nodetype=subscriptn) and is_implicit_pointer_object_type(tsubscriptnode(n).left.resultdef)) or
-             ((n.nodetype in [addn,subn,muln,unaryminusn]) and (n.localswitches*[cs_check_overflow,cs_check_range]<>[]))
+             ((n.nodetype in [addn,subn,muln,unaryminusn]) and (n.localswitches*[cs_check_overflow,cs_check_range]<>[])) or
+             { float operations could throw an exception }
+             ((n.nodetype in [addn,subn,muln,slashn,unaryminusn,equaln,unequaln,gten,gtn,lten,ltn]) and is_real_or_cextended(tunarynode(n).left.resultdef))
             )
            ) or
            ((n.nodetype=loadn) and

+ 12 - 0
tests/webtbs/tw37398.pp

@@ -0,0 +1,12 @@
+program testnan;
+
+{$mode objfpc}{$H+}
+
+uses math;
+var d: double;
+  temp: Boolean;
+begin
+  d := NaN;
+  temp := IsNan(d) or (d = 0);
+  writeln(temp);
+end.