This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix op/infnan.t test fails with NAN conversion on VC 6
authorDaniel Dragan <bulk88@hotmail.com>
Tue, 26 Jan 2016 07:27:49 +0000 (02:27 -0500)
committerSteve Hay <steve.m.hay@googlemail.com>
Thu, 28 Jan 2016 08:13:29 +0000 (08:13 +0000)
fixes
ok 443 - NAN is NaN numerically (by not being NaN)
ok 444 - NAN value stringifies as NaN
ok 445 - nan is NaN numerically (by not being NaN)
not ok 446 - nan value stringifies as NaN
ok 447 - qnan is NaN numerically (by not being NaN)
not ok 448 - qnan value stringifies as NaN
ok 449 - SNAN is NaN numerically (by not being NaN)
not ok 450 - SNAN value stringifies as NaN
ok 451 - NanQ is NaN numerically (by not being NaN)
not ok 452 - NanQ value stringifies as NaN
ok 453 - NANS is NaN numerically (by not being NaN)
not ok 454 - NANS value stringifies as NaN
ok 455 - 1.\#QNAN is NaN numerically (by not being NaN)
not ok 456 - 1.\#QNAN value stringifies as NaN
ok 457 - +1\#SNAN is NaN numerically (by not being NaN)
not ok 458 - +1\#SNAN value stringifies as NaN
ok 459 - -1.\#NAN is NaN numerically (by not being NaN)
not ok 460 - -1.\#NAN value stringifies as NaN
ok 461 - 1\#IND is NaN numerically (by not being NaN)
not ok 462 - 1\#IND value stringifies as NaN
ok 463 - 1.\#IND00 is NaN numerically (by not being NaN)
not ok 464 - 1.\#IND00 value stringifies as NaN
ok 465 - NAN(123) is NaN numerically (by not being NaN)
not ok 466 - NAN(123) value stringifies as NaN
ok 467 - NaN is not lt zero
ok 468 - NaN is not == zero
ok 469 - NaN is not gt zero
ok 470 - NaN is not lt NaN
ok 471 - NaN is not gt NaN

Caused by commit 230ee21f3e from ~5.23.5. Add special casing for VC6.

The NV to IV casts on VC are a function call called __ftol, skip executing
the NV to IV casts if the logic test tests will follow "TARGn" branch
because the NV and IV values are !=.

pp.c
pp_hot.c

diff --git a/pp.c b/pp.c
index 016023e..885ec84 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -1364,9 +1364,14 @@ PP(pp_multiply)
             NV nr = SvNVX(svr);
             NV result;
 
-            il = (IV)nl;
-            ir = (IV)nr;
-            if (nl == (NV)il && nr == (NV)ir)
+            if (
+#if defined(NAN_COMPARE_BROKEN) && defined(Perl_isnan)
+                !Perl_isnan(nl) && nl == (NV)(il = (IV)nl)
+                && !Perl_isnan(nr) && nr == (NV)(ir = (IV)nr)
+#else
+                nl == (NV)(il = (IV)nl) && nr == (NV)(ir = (IV)nr)
+#endif
+                )
                 /* nothing was lost by converting to IVs */
                 goto do_iv;
             SP--;
@@ -1940,9 +1945,14 @@ PP(pp_subtract)
             NV nl = SvNVX(svl);
             NV nr = SvNVX(svr);
 
-            il = (IV)nl;
-            ir = (IV)nr;
-            if (nl == (NV)il && nr == (NV)ir)
+            if (
+#if defined(NAN_COMPARE_BROKEN) && defined(Perl_isnan)
+                !Perl_isnan(nl) && nl == (NV)(il = (IV)nl)
+                && !Perl_isnan(nr) && nr == (NV)(ir = (IV)nr)
+#else
+                nl == (NV)(il = (IV)nl) && nr == (NV)(ir = (IV)nr)
+#endif
+                )
                 /* nothing was lost by converting to IVs */
                 goto do_iv;
             SP--;
index b80efae..986367c 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -624,9 +624,14 @@ PP(pp_add)
             NV nl = SvNVX(svl);
             NV nr = SvNVX(svr);
 
-            il = (IV)nl;
-            ir = (IV)nr;
-            if (nl == (NV)il && nr == (NV)ir)
+            if (
+#if defined(NAN_COMPARE_BROKEN) && defined(Perl_isnan)
+                !Perl_isnan(nl) && nl == (NV)(il = (IV)nl)
+                && !Perl_isnan(nr) && nr == (NV)(ir = (IV)nr)
+#else
+                nl == (NV)(il = (IV)nl) && nr == (NV)(ir = (IV)nr)
+#endif
+                )
                 /* nothing was lost by converting to IVs */
                 goto do_iv;
             SP--;