Skip to content

Commit bd9a4cf

Browse files
committed
Workaround miscompilation bug of clang on windows in tests with -ffast-math.
1 parent c2d8146 commit bd9a4cf

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tests/ComparisonTests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ void TestCompareOptWithOpt(Val1 val1, Val2 val2, Comparer comparer)
3535
std::optional<typename Opt1::value_type> const std1{val1};
3636
std::optional<typename Opt2::value_type> const std2{val2};
3737

38-
// Workaround some miscompilation bug seen in clang 20.1.4 on Windows with
38+
// Work around some miscompilation bug seen in clang 20.1.4 and 21.1.3 on Windows with
3939
// the flags "-std=c++20 -O3 -DNDEBUG -ffast-math" for the call
4040
// (TestCompareOptWithOpt<std::optional<int>, std::optional<double>>(42, NaN, comparer), ...)
4141
// The compilation succeeds, but the ASSERTs fail.
4242
// I guess it has something to do with the use of a NaN and -ffast-math; this is notoriously broken.
4343
// Adding the following dummy line works around the issue for some reason.
44-
#if defined(TINY_OPTIONAL_CLANG_BUILD) && __clang_major__ == 20 && defined(__FAST_MATH__) && defined(NDEBUG)
44+
#if defined(TINY_OPTIONAL_CLANG_BUILD) && (__clang_major__ == 20 || __clang_major__ == 21) && defined(__FAST_MATH__) && defined(NDEBUG)
4545
[[maybe_unused]] auto volatile const dummy = (comparer(opt1, opt2) < 0 ? "<" : comparer(opt1, opt2) > 0 ? ">" : "==");
4646
#endif
4747

0 commit comments

Comments
 (0)