From cfbb2278a0ad3dccc3c93f7dbe873700c3c91db4 Mon Sep 17 00:00:00 2001 From: Eduardo Roman Date: Wed, 16 Jan 2019 11:53:04 -0800 Subject: [PATCH] guard against INF values in CompactValue Summary: After this diff D13403925 that got rid of `-ffast-math` we started to have a very odd behavior on Yoga when using release builds. After digging a while we found that certain set of conditions on O2 and O3 optimization levels was causing Origami to set some `INFINITE` values on Yoga. We found the root of the problem and fix it on Origami side. But I'm wondering if guarding agains `INFINITE` on Yoga side would be good too. Since now Yoga it's not using `-ffast-math` anymore, and I think infinite is not a a valid value anywhere on Yoga side, it seems to support the reason to guard against it. I'm happy to abandon this diff if you guys think this is not a good solution. Reviewed By: davidaurelio Differential Revision: D13679319 fbshipit-source-id: 061448fea9d1a8496362ff07dc46b546e7f1ffa3 --- ReactCommon/yoga/yoga/CompactValue.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ReactCommon/yoga/yoga/CompactValue.h b/ReactCommon/yoga/yoga/CompactValue.h index 9c9a92e0581..3cc36a4889e 100644 --- a/ReactCommon/yoga/yoga/CompactValue.h +++ b/ReactCommon/yoga/yoga/CompactValue.h @@ -70,7 +70,8 @@ public: template static CompactValue ofMaybe(float value) noexcept { - return std::isnan(value) ? ofUndefined() : of(value); + return std::isnan(value) || std::isinf(value) ? ofUndefined() + : of(value); } static constexpr CompactValue ofZero() noexcept {