From e0a9a3836cb07578cfbc0fd5265909684c4ca56b Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Tue, 25 Oct 2022 22:56:43 +0000 Subject: [PATCH] Fix stdio -NaN tests for riscv64. riscv64 hates nans. From the spec: "Except when otherwise stated, if the result of a floating-point operation is NaN, it is the canonical NaN. The canonical NaN has a positive sign and all significand bits clear except the MSB, a.k.a. the quiet bit." This broke our tests here because the float-to-double instruction isn't one of the "otherwise stated" cases, so it turns -nanf() into +nan(). The sign manipulation instructions are "otherwise stated" cases, though, so as long as we avoid a conversion we're fine. And we didn't actually _need_ a float here (pretty much by definition, since varargs means you always end up with a double anyway), so we can just simplify things and switch to using doubles directly to fix the tests. Test: bionic-unit-tests-static Change-Id: I13aa452dd6cc8708275f7676b37fc772b37a7b32 --- tests/stdio_test.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/stdio_test.cpp b/tests/stdio_test.cpp index 21b3f6cf9..acc7ccd77 100644 --- a/tests/stdio_test.cpp +++ b/tests/stdio_test.cpp @@ -490,22 +490,22 @@ static void CheckInfNan(int snprintf_fn(T*, size_t, const T*, ...), // NaN. - snprintf_fn(buf, sizeof(buf), fmt, nanf("")); + snprintf_fn(buf, sizeof(buf), fmt, nan("")); EXPECT_STREQ(nan_, buf) << fmt; EXPECT_EQ(1, sscanf_fn(buf, fmt, &f)); EXPECT_TRUE(isnan(f)); - snprintf_fn(buf, sizeof(buf), fmt, -nanf("")); + snprintf_fn(buf, sizeof(buf), fmt, -nan("")); EXPECT_STREQ(minus_nan, buf) << fmt; EXPECT_EQ(1, sscanf_fn(buf, fmt, &f)); EXPECT_TRUE(isnan(f)); - snprintf_fn(buf, sizeof(buf), fmt_plus, nanf("")); + snprintf_fn(buf, sizeof(buf), fmt_plus, nan("")); EXPECT_STREQ(plus_nan, buf) << fmt_plus; EXPECT_EQ(1, sscanf_fn(buf, fmt, &f)); EXPECT_TRUE(isnan(f)); - snprintf_fn(buf, sizeof(buf), fmt_plus, -nanf("")); + snprintf_fn(buf, sizeof(buf), fmt_plus, -nan("")); EXPECT_STREQ(minus_nan, buf) << fmt_plus; EXPECT_EQ(1, sscanf_fn(buf, fmt, &f)); EXPECT_TRUE(isnan(f));