From 504038eed0c3f3f8d3286aa1b620bfe86505885d Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Wed, 23 Sep 2026 14:33:27 +0100 Subject: [PATCH] ANGLE: skip excess-precision-sensitive roundToNearest static_asserts on x87 On 32-bit x86 targets with x87 FP (FLT_EVAL_METHOD == 2), constexpr float/double arithmetic is performed at 80-bit extended precision, so 0.49999997f + 0.5f compares to long-double 0.99999996... != 1.0 and the static_assert fails. The runtime bias trick remains correct (the result is still cast back to float and rounded). Skip the compile-time checks when __FLT_EVAL_METHOD__ != 0. Signed-off-by: Daniel Golle --- Source/ThirdParty/ANGLE/src/common/mathutil.h | 2 ++ 1 file changed, 2 insertions(+) --- a/Source/ThirdParty/ANGLE/src/common/mathutil.h +++ b/Source/ThirdParty/ANGLE/src/common/mathutil.h @@ -615,10 +615,12 @@ inline R roundToNearest(T input) // On armv8, this expression is compiled to a dedicated round-to-nearest instruction return static_cast(std::round(input)); #else +#if !defined(__FLT_EVAL_METHOD__) || __FLT_EVAL_METHOD__ == 0 static_assert(0.49999997f < 0.5f); static_assert(0.49999997f + 0.5f == 1.0f); static_assert(0.49999999999999994 < 0.5); static_assert(0.49999999999999994 + 0.5 == 1.0); +#endif constexpr T bias = sizeof(T) == 8 ? 0.49999999999999994 : 0.49999997f; return static_cast(input + (std::is_signed::value ? std::copysign(bias, input) : bias)); #endif