From e5cb9d7df9bae8f1e69b04dbe379892b5f499d86 Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Tue, 7 May 2024 09:34:50 +0100 Subject: [PATCH 1/2] Force ffp-contract to off --- NEWS | 2 ++ configure.ac | 3 +++ 2 files changed, 5 insertions(+) diff --git a/NEWS b/NEWS index 31e8843282c..235353a39a1 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,8 @@ PHP NEWS - Core: . Fixed bug GH-13970 (Incorrect validation of #[Attribute] flags type for non-compile-time expressions). (ilutov) + . Fixed bug GH-14140 (Floating point bug in range operation on Apple Silicon + hardware). (Derick, Saki) - DOM: . Fix crashes when entity declaration is removed while still having entity diff --git a/configure.ac b/configure.ac index b8b8d413421..ba4a2654a5f 100644 --- a/configure.ac +++ b/configure.ac @@ -218,6 +218,9 @@ case $host_cpu in ;; esac +dnl See https://github.com/php/php-src/issues/14140 +AX_CHECK_COMPILE_FLAG([-ffp-contract=off], [CFLAGS="$CFLAGS -ffp-contract=off"]) + dnl Mark symbols hidden by default if the compiler (for example, gcc >= 4) dnl supports it. This can help reduce the binary size and startup time. AX_CHECK_COMPILE_FLAG([-fvisibility=hidden], From 0a8fbef996fe2b104c4eb3a978b4decf6292551e Mon Sep 17 00:00:00 2001 From: Saki Takamachi Date: Sat, 18 May 2024 07:08:39 +0900 Subject: [PATCH 2/2] Added test --- ext/standard/tests/array/gh14140.phpt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 ext/standard/tests/array/gh14140.phpt diff --git a/ext/standard/tests/array/gh14140.phpt b/ext/standard/tests/array/gh14140.phpt new file mode 100644 index 00000000000..2bc17a236a7 --- /dev/null +++ b/ext/standard/tests/array/gh14140.phpt @@ -0,0 +1,21 @@ +--TEST-- +GH-14140: Floating point bug in range operation on Apple Silicon hardware +--FILE-- + +--EXPECT-- +Array +( + [0] => -0.03 + [1] => -0.02 + [2] => -0.01 + [3] => 0 + [4] => 0.01 + [5] => 0.02 + [6] => 0.03 +)