From a21bbf61f1c82792c8dfd4392ba378fc457e5477 Mon Sep 17 00:00:00 2001 From: Nano Date: Wed, 10 May 2023 19:46:35 +0800 Subject: [PATCH] fix(wechat_code): Modify `isnan` for compatibility with -ffast_math fix #3150 --- modules/wechat_qrcode/src/zxing/zxing.hpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/wechat_qrcode/src/zxing/zxing.hpp b/modules/wechat_qrcode/src/zxing/zxing.hpp index 76efae22c87..1cfb8f0e3a1 100644 --- a/modules/wechat_qrcode/src/zxing/zxing.hpp +++ b/modules/wechat_qrcode/src/zxing/zxing.hpp @@ -54,8 +54,14 @@ typedef unsigned char boolean; #include namespace zxing { -inline bool isnan(float v) { return std::isnan(v); } -inline bool isnan(double v) { return std::isnan(v); } +inline bool isnan(float v) { + union { float v; uint32_t x; } u = { v }; + return (u.x & 0x7fffffffu) > 0x7f800000u; +} +inline bool isnan(double v) { + union { double v; uint64_t x; } u = { v }; + return (u.x & ~0x8000000000000000uLL) > 0x7ff0000000000000uLL; +} inline float nan() { return std::numeric_limits::quiet_NaN(); } } // namespace zxing