From 17b7fc82db31eca7204f11061208f68e08968e7d Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Thu, 1 Oct 2026 03:56:29 -0700 Subject: [PATCH] Avoid invalid errata enum values in tests (#2034) Summary: Pull Request resolved: https://github.com/react/yoga/pull/2034 Replace bitwise complements of the unscoped YGErrata enum with masks derived from YGErrataAll. The complement sets high bits outside the enum's valid range and makes the sanitizer-enabled yoga-github-first-compatibility workflow fail, even though the intended operation is only to clear one known errata bit. This preserves the existing test behavior without changing Yoga's public API or ABI. Differential Revision: D122761729 --- tests/YGAutoMinSizeTest.cpp | 6 ++++-- tests/YGFirstChildMinWidthTest.cpp | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/YGAutoMinSizeTest.cpp b/tests/YGAutoMinSizeTest.cpp index 02ac9fd2a4..750f6df1c2 100644 --- a/tests/YGAutoMinSizeTest.cpp +++ b/tests/YGAutoMinSizeTest.cpp @@ -59,7 +59,8 @@ YGConfigRef makeWebConfig(bool useAutoMinSize) { const YGErrata errata = YGConfigGetErrata(config); YGConfigSetErrata( config, - static_cast(errata & ~YGErrataMinSizeUndefinedInsteadOfAuto)); + static_cast( + errata & (YGErrataAll ^ YGErrataMinSizeUndefinedInsteadOfAuto))); } return config; } @@ -566,7 +567,8 @@ TEST(YogaAutoMinSize, errata_bit_round_trips) { YGConfigSetErrata( config, static_cast( - YGConfigGetErrata(config) & ~YGErrataMinSizeUndefinedInsteadOfAuto)); + YGConfigGetErrata(config) & + (YGErrataAll ^ YGErrataMinSizeUndefinedInsteadOfAuto))); EXPECT_EQ( YGConfigGetErrata(config) & YGErrataMinSizeUndefinedInsteadOfAuto, 0); diff --git a/tests/YGFirstChildMinWidthTest.cpp b/tests/YGFirstChildMinWidthTest.cpp index 6eaec8a4f5..eb409e8802 100644 --- a/tests/YGFirstChildMinWidthTest.cpp +++ b/tests/YGFirstChildMinWidthTest.cpp @@ -29,7 +29,8 @@ YGConfigRef makeFixedConfig() { const YGErrata errata = YGConfigGetErrata(config); YGConfigSetErrata( config, - static_cast(errata & ~YGErrataFlexFirstPassUsesRunningTotals)); + static_cast( + errata & (YGErrataAll ^ YGErrataFlexFirstPassUsesRunningTotals))); return config; } @@ -125,7 +126,8 @@ TEST(YGFirstChildMinWidth, errata_bit_round_trips) { YGConfigSetErrata( config, static_cast( - YGConfigGetErrata(config) & ~YGErrataFlexFirstPassUsesRunningTotals)); + YGConfigGetErrata(config) & + (YGErrataAll ^ YGErrataFlexFirstPassUsesRunningTotals))); EXPECT_EQ( YGConfigGetErrata(config) & YGErrataFlexFirstPassUsesRunningTotals, 0);