summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Faulds <ajf@ajf.me>2017-02-05 01:30:20 +0000
committerAndrea Faulds <ajf@ajf.me>2017-02-05 01:30:20 +0000
commit21d7878690c18124fa788f2aa22e505a4fa6ceeb (patch)
treed458ad2768bb302bc23ef8f6835a4249c351dae9
parentdcaf4da8a6832f5bc1d0dabee08686cd5cf9e801 (diff)
downloadphp-git-21d7878690c18124fa788f2aa22e505a4fa6ceeb.tar.gz
Fix bug #73954
-rw-r--r--NEWS1
-rw-r--r--Zend/configure.in2
-rw-r--r--Zend/tests/bug73954.phpt23
-rw-r--r--configure.in2
4 files changed, 26 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 102c9eae00..adc80db1d3 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,7 @@ PHP NEWS
(Nikita)
. Fixed bug #73998 (array_key_exists fails on arrays created by
get_object_vars). (mhagstrand)
+ . Fixed bug #73954 (NAN check fails on Alpine Linux with musl). (Andrea)
- GD:
. Fixed bug #74031 (ReflectionFunction for imagepng is missing last two
diff --git a/Zend/configure.in b/Zend/configure.in
index 29551d924c..3c7915156c 100644
--- a/Zend/configure.in
+++ b/Zend/configure.in
@@ -75,7 +75,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
#elif defined(HAVE_FPCLASS)
#define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
#else
-#define zend_isnan(a) 0
+#define zend_isnan(a) ((a) != (a))
#endif
#endif
diff --git a/Zend/tests/bug73954.phpt b/Zend/tests/bug73954.phpt
new file mode 100644
index 0000000000..918f24b0f1
--- /dev/null
+++ b/Zend/tests/bug73954.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Bug #73954 (NAN check fails on Alpine Linux with musl)
+--FILE--
+<?php
+
+var_dump(NAN);
+var_dump(is_nan(NAN));
+
+function takes_int(int $int) {
+}
+
+takes_int(NAN);
+
+?>
+--EXPECTF--
+float(NAN)
+bool(true)
+
+Fatal error: Uncaught TypeError: Argument 1 passed to takes_int() must be of the type integer, float given, called in %s on line 9 and defined in %s:6
+Stack trace:
+#0 %s(9): takes_int(NAN)
+#1 {main}
+ thrown in %s on line 6
diff --git a/configure.in b/configure.in
index a61a85d0fc..b5a3919e5f 100644
--- a/configure.in
+++ b/configure.in
@@ -80,7 +80,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
#elif defined(HAVE_FPCLASS)
#define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
#else
-#define zend_isnan(a) 0
+#define zend_isnan(a) ((a) != (a))
#endif
#endif