This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
pack('f', $NAN) must account for NAN_COMPARE_BROKEN platforms
authorDaniel Dragan <bulk88@hotmail.com>
Tue, 19 May 2015 17:22:40 +0000 (13:22 -0400)
committerRicardo Signes <rjbs@cpan.org>
Thu, 21 May 2015 00:37:58 +0000 (20:37 -0400)
VC6 was returning either packed float +inf or packed float -inf
(I dont remember) instead of packed float NAN in t/op/infnan.t .

This fixes #125203

pp_pack.c

index 1d732a8..cf1074e 100644 (file)
--- a/pp_pack.c
+++ b/pp_pack.c
@@ -2672,6 +2672,11 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist )
                    afloat = -FLT_MAX;
                else afloat = (float)anv;
 # else
+#if defined(NAN_COMPARE_BROKEN) && defined(Perl_isnan)
+               if(Perl_isnan(anv))
+                   afloat = (float)NV_NAN;
+               else
+#endif
                 /* a simple cast to float is undefined if outside
                  * the range of values that can be represented */
                afloat = (float)(anv >  FLT_MAX ?  NV_INF :