com php-src: Fix bug #73954: NEWS Zend/configure.in Zend/tests/bug73954.phpt configure.in

[email protected] (Andrea Faulds)
Newsgroups php.cvs
Message-ID <[email protected]>
Commit:    21d7878690c18124fa788f2aa22e505a4fa6ceeb
Author:    Andrea Faulds <[email protected]>         Sun, 5 Feb 2017 01:30:20 +0000
Parents:   dcaf4da8a6832f5bc1d0dabee08686cd5cf9e801
Branches:  PHP-7.0

Link:       http://git.php.net/?p=php-src.git;a=commitdiff;h=21d7878690c18124fa788f2aa22e505a4fa6ceeb

Log:
Fix bug #73954

Bugs:
https://bugs.php.net/73954

Changed paths:
  M  NEWS
  M  Zend/configure.in
  A  Zend/tests/bug73954.phpt
  M  configure.in


Diff:
diff --git a/NEWS b/NEWS
index 102c9ea..adc80db 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 29551d9..3c79151 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 0000000..918f24b
--- /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 a61a85d..b5a3919 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.