This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Use Perl_isfinite().
authorJarkko Hietaniemi <jhi@iki.fi>
Mon, 18 Aug 2014 13:12:09 +0000 (09:12 -0400)
committerJarkko Hietaniemi <jhi@iki.fi>
Wed, 20 Aug 2014 13:33:10 +0000 (09:33 -0400)
Also kill obsolete/wrong comment: Perl_frexp is not casting its
argument to NV, and if USE_LONG_DOUBLE Perl_frexp is frexpl.
And if we do have long double and don't have frexpl, it is unclear
what should we do? (in this particular case, casting to double might
be the best possible thing to do anyway.)

sv.c

diff --git a/sv.c b/sv.c
index 92c34a8..8f208be 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -11701,12 +11701,10 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
                : SvNV(argsv);
 
            need = 0;
-           /* nv * 0 will be NaN for NaN, +Inf and -Inf, and 0 for anything
-              else. frexp() has some unspecified behaviour for those three */
-           if (c != 'e' && c != 'E' && (nv * 0) == 0) {
+           /* frexp() has some unspecified behaviour for nan/inf,
+             * so let's avoid calling that. */
+           if (c != 'e' && c != 'E' && Perl_isfinite(nv)) {
                 i = PERL_INT_MIN;
-                /* FIXME: if HAS_LONG_DOUBLE but not USE_LONG_DOUBLE this
-                   will cast our (long double) to (double) */
                 (void)Perl_frexp(nv, &i);
                 if (i == PERL_INT_MIN)
                     Perl_die(aTHX_ "panic: frexp");