summaryrefslogtreecommitdiff
path: root/inline.h
diff options
context:
space:
mode:
Diffstat (limited to 'inline.h')
-rw-r--r--inline.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/inline.h b/inline.h
index 6fbd5abfea..29ad5a2d4d 100644
--- a/inline.h
+++ b/inline.h
@@ -1962,15 +1962,17 @@ S_lossless_NV_to_IV(const NV nv, IV *ivp)
PERL_ARGS_ASSERT_LOSSLESS_NV_TO_IV;
-# if defined(Perl_isnan)
-
+# if defined(NAN_COMPARE_BROKEN) && defined(Perl_isnan)
+ /* Normally any comparison with a NaN returns false; if we can't rely
+ * on that behaviour, check explicitly */
if (UNLIKELY(Perl_isnan(nv))) {
return FALSE;
}
-
# endif
- if (UNLIKELY(nv < IV_MIN) || UNLIKELY(nv > IV_MAX)) {
+ /* Written this way so that with an always-false NaN comparison we
+ * return false */
+ if (!(LIKELY(nv >= IV_MIN) && LIKELY(nv <= IV_MAX))) {
return FALSE;
}