[libc-commits] [libc] [libc] Fix warnings emitted by GCC (PR #98751)
via libc-commits
libc-commits at lists.llvm.org
Mon Jul 15 03:32:09 PDT 2024
https://github.com/overmighty updated https://github.com/llvm/llvm-project/pull/98751
>From 17d7fcc38489154a87d0da9acf64b62b93d7a098 Mon Sep 17 00:00:00 2001
From: OverMighty <its.overmighty at gmail.com>
Date: Sat, 13 Jul 2024 18:07:35 +0200
Subject: [PATCH 1/3] [libc] Fix warnings emitted by GCC
Fixes #98709.
---
.../test/src/__support/FPUtil/fpbits_test.cpp | 1 +
libc/test/src/__support/big_int_test.cpp | 7 +-
libc/test/src/math/RoundToIntegerTest.h | 4 +-
libc/test/src/math/smoke/FMaxTest.h | 20 +--
libc/test/src/math/smoke/FMaximumMagNumTest.h | 24 +--
libc/test/src/math/smoke/FMaximumMagTest.h | 20 +--
libc/test/src/math/smoke/FMaximumNumTest.h | 24 +--
libc/test/src/math/smoke/FMaximumTest.h | 20 +--
libc/test/src/math/smoke/FMinTest.h | 20 +--
libc/test/src/math/smoke/FMinimumMagNumTest.h | 24 +--
libc/test/src/math/smoke/FMinimumMagTest.h | 20 +--
libc/test/src/math/smoke/FMinimumNumTest.h | 24 +--
libc/test/src/math/smoke/FMinimumTest.h | 20 +--
libc/test/src/math/smoke/FModTest.h | 170 +++++++++---------
libc/test/src/math/smoke/FrexpTest.h | 4 +-
libc/test/src/math/smoke/ILogbTest.h | 16 +-
libc/test/src/math/smoke/LogbTest.h | 4 +-
libc/test/src/stdio/sprintf_test.cpp | 7 +-
18 files changed, 218 insertions(+), 211 deletions(-)
diff --git a/libc/test/src/__support/FPUtil/fpbits_test.cpp b/libc/test/src/__support/FPUtil/fpbits_test.cpp
index af20b1a0bdc7e..99acc03010344 100644
--- a/libc/test/src/__support/FPUtil/fpbits_test.cpp
+++ b/libc/test/src/__support/FPUtil/fpbits_test.cpp
@@ -238,6 +238,7 @@ template <typename T> constexpr auto make(Sign sign, FP fp) {
case FP::QUIET_NAN:
return T::quiet_nan(sign);
}
+ __builtin_unreachable();
}
// Tests all properties for all types of float.
diff --git a/libc/test/src/__support/big_int_test.cpp b/libc/test/src/__support/big_int_test.cpp
index 2c3d57755cd5b..a1ce69baaae29 100644
--- a/libc/test/src/__support/big_int_test.cpp
+++ b/libc/test/src/__support/big_int_test.cpp
@@ -32,6 +32,7 @@ template <typename T> auto create(Value value) {
case MAX:
return T::max();
}
+ __builtin_unreachable();
}
using Types = testing::TypeList< //
@@ -264,7 +265,11 @@ TEST(LlvmLibcUIntClassTest, BitCastToFromNativeFloat128) {
TEST(LlvmLibcUIntClassTest, BitCastToFromNativeFloat16) {
static_assert(cpp::is_trivially_copyable<LL_UInt16>::value);
static_assert(sizeof(LL_UInt16) == sizeof(float16));
- const float16 array[] = {0, 0.1, 1};
+ const float16 array[] = {
+ static_cast<float16>(0.0),
+ static_cast<float16>(0.1),
+ static_cast<float16>(1.0),
+ };
for (float16 value : array) {
LL_UInt16 back = cpp::bit_cast<LL_UInt16>(value);
float16 forth = cpp::bit_cast<float16>(back);
diff --git a/libc/test/src/math/RoundToIntegerTest.h b/libc/test/src/math/RoundToIntegerTest.h
index 2b1c643267590..d3e557a847953 100644
--- a/libc/test/src/math/RoundToIntegerTest.h
+++ b/libc/test/src/math/RoundToIntegerTest.h
@@ -167,7 +167,9 @@ class RoundToIntegerTestTemplate
}
void do_fractions_test(RoundToIntegerFunc func, int mode) {
- constexpr F FRACTIONS[] = {0.5, -0.5, 0.115, -0.115, 0.715, -0.715};
+ constexpr F FRACTIONS[] = {
+ F(0.5), F(-0.5), F(0.115), F(-0.115), F(0.715), F(-0.715),
+ };
for (F x : FRACTIONS) {
long mpfr_long_result;
bool erangeflag;
diff --git a/libc/test/src/math/smoke/FMaxTest.h b/libc/test/src/math/smoke/FMaxTest.h
index f4c78b5d04b5b..1cb105aa00778 100644
--- a/libc/test/src/math/smoke/FMaxTest.h
+++ b/libc/test/src/math/smoke/FMaxTest.h
@@ -25,8 +25,8 @@ class FMaxTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
void testNaN(FMaxFunc func) {
EXPECT_FP_EQ(inf, func(aNaN, inf));
EXPECT_FP_EQ(neg_inf, func(neg_inf, aNaN));
- EXPECT_FP_EQ(0.0, func(aNaN, 0.0));
- EXPECT_FP_EQ(-0.0, func(-0.0, aNaN));
+ EXPECT_FP_EQ(zero, func(aNaN, zero));
+ EXPECT_FP_EQ(neg_zero, func(neg_zero, aNaN));
EXPECT_FP_EQ(T(-1.2345), func(aNaN, T(-1.2345)));
EXPECT_FP_EQ(T(1.2345), func(T(1.2345), aNaN));
EXPECT_FP_EQ(aNaN, func(aNaN, aNaN));
@@ -34,25 +34,25 @@ class FMaxTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
void testInfArg(FMaxFunc func) {
EXPECT_FP_EQ(inf, func(neg_inf, inf));
- EXPECT_FP_EQ(inf, func(inf, 0.0));
- EXPECT_FP_EQ(inf, func(-0.0, inf));
+ EXPECT_FP_EQ(inf, func(inf, zero));
+ EXPECT_FP_EQ(inf, func(neg_zero, inf));
EXPECT_FP_EQ(inf, func(inf, T(1.2345)));
EXPECT_FP_EQ(inf, func(T(-1.2345), inf));
}
void testNegInfArg(FMaxFunc func) {
EXPECT_FP_EQ(inf, func(inf, neg_inf));
- EXPECT_FP_EQ(0.0, func(neg_inf, 0.0));
- EXPECT_FP_EQ(-0.0, func(-0.0, neg_inf));
+ EXPECT_FP_EQ(zero, func(neg_inf, zero));
+ EXPECT_FP_EQ(neg_zero, func(neg_zero, neg_inf));
EXPECT_FP_EQ(T(-1.2345), func(neg_inf, T(-1.2345)));
EXPECT_FP_EQ(T(1.2345), func(T(1.2345), neg_inf));
}
void testBothZero(FMaxFunc func) {
- EXPECT_FP_EQ(0.0, func(0.0, 0.0));
- EXPECT_FP_EQ(0.0, func(-0.0, 0.0));
- EXPECT_FP_EQ(0.0, func(0.0, -0.0));
- EXPECT_FP_EQ(-0.0, func(-0.0, -0.0));
+ EXPECT_FP_EQ(zero, func(zero, zero));
+ EXPECT_FP_EQ(zero, func(neg_zero, zero));
+ EXPECT_FP_EQ(zero, func(zero, neg_zero));
+ EXPECT_FP_EQ(neg_zero, func(neg_zero, neg_zero));
}
void testRange(FMaxFunc func) {
diff --git a/libc/test/src/math/smoke/FMaximumMagNumTest.h b/libc/test/src/math/smoke/FMaximumMagNumTest.h
index 726f87059fc64..b52169e5e8680 100644
--- a/libc/test/src/math/smoke/FMaximumMagNumTest.h
+++ b/libc/test/src/math/smoke/FMaximumMagNumTest.h
@@ -30,10 +30,10 @@ class FMaximumMagNumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
EXPECT_FP_EQ(neg_inf, func(neg_inf, aNaN));
EXPECT_FP_EQ_WITH_EXCEPTION(neg_inf, func(neg_inf, sNaN), FE_INVALID);
EXPECT_EQ(FPBits(aNaN).uintval(), FPBits(func(aNaN, aNaN)).uintval());
- EXPECT_FP_EQ(0.0, func(aNaN, 0.0));
- EXPECT_FP_EQ(-0.0, func(-0.0, aNaN));
- EXPECT_FP_EQ_WITH_EXCEPTION(0.0, func(sNaN, 0.0), FE_INVALID);
- EXPECT_FP_EQ_WITH_EXCEPTION(-0.0, func(-0.0, sNaN), FE_INVALID);
+ EXPECT_FP_EQ(zero, func(aNaN, zero));
+ EXPECT_FP_EQ(neg_zero, func(neg_zero, aNaN));
+ EXPECT_FP_EQ_WITH_EXCEPTION(zero, func(sNaN, zero), FE_INVALID);
+ EXPECT_FP_EQ_WITH_EXCEPTION(neg_zero, func(neg_zero, sNaN), FE_INVALID);
EXPECT_FP_EQ(T(-1.2345), func(aNaN, T(-1.2345)));
EXPECT_FP_EQ(T(1.2345), func(T(1.2345), aNaN));
EXPECT_FP_EQ_WITH_EXCEPTION(T(-1.2345), func(sNaN, T(-1.2345)), FE_INVALID);
@@ -47,25 +47,25 @@ class FMaximumMagNumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
void testInfArg(FMaximumMagNumFunc func) {
EXPECT_FP_EQ(inf, func(neg_inf, inf));
- EXPECT_FP_EQ(inf, func(inf, 0.0));
- EXPECT_FP_EQ(inf, func(-0.0, inf));
+ EXPECT_FP_EQ(inf, func(inf, zero));
+ EXPECT_FP_EQ(inf, func(neg_zero, inf));
EXPECT_FP_EQ(inf, func(inf, T(1.2345)));
EXPECT_FP_EQ(inf, func(T(-1.2345), inf));
}
void testNegInfArg(FMaximumMagNumFunc func) {
EXPECT_FP_EQ(inf, func(inf, neg_inf));
- EXPECT_FP_EQ(neg_inf, func(neg_inf, 0.0));
- EXPECT_FP_EQ(neg_inf, func(-0.0, neg_inf));
+ EXPECT_FP_EQ(neg_inf, func(neg_inf, zero));
+ EXPECT_FP_EQ(neg_inf, func(neg_zero, neg_inf));
EXPECT_FP_EQ(neg_inf, func(neg_inf, T(-1.2345)));
EXPECT_FP_EQ(neg_inf, func(T(1.2345), neg_inf));
}
void testBothZero(FMaximumMagNumFunc func) {
- EXPECT_FP_EQ(0.0, func(0.0, 0.0));
- EXPECT_FP_EQ(0.0, func(-0.0, 0.0));
- EXPECT_FP_EQ(0.0, func(0.0, -0.0));
- EXPECT_FP_EQ(-0.0, func(-0.0, -0.0));
+ EXPECT_FP_EQ(zero, func(zero, zero));
+ EXPECT_FP_EQ(zero, func(neg_zero, zero));
+ EXPECT_FP_EQ(zero, func(zero, neg_zero));
+ EXPECT_FP_EQ(neg_zero, func(neg_zero, neg_zero));
}
void testRange(FMaximumMagNumFunc func) {
diff --git a/libc/test/src/math/smoke/FMaximumMagTest.h b/libc/test/src/math/smoke/FMaximumMagTest.h
index b5b2c1ca79abc..81a232d96ec94 100644
--- a/libc/test/src/math/smoke/FMaximumMagTest.h
+++ b/libc/test/src/math/smoke/FMaximumMagTest.h
@@ -26,8 +26,8 @@ class FMaximumMagTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
void testNaN(FMaximumMagFunc func) {
EXPECT_FP_EQ(aNaN, func(aNaN, inf));
EXPECT_FP_EQ(aNaN, func(neg_inf, aNaN));
- EXPECT_FP_EQ(aNaN, func(aNaN, 0.0));
- EXPECT_FP_EQ(aNaN, func(-0.0, aNaN));
+ EXPECT_FP_EQ(aNaN, func(aNaN, zero));
+ EXPECT_FP_EQ(aNaN, func(neg_zero, aNaN));
EXPECT_FP_EQ(aNaN, func(aNaN, T(-1.2345)));
EXPECT_FP_EQ(aNaN, func(T(1.2345), aNaN));
EXPECT_FP_EQ(aNaN, func(aNaN, aNaN));
@@ -35,25 +35,25 @@ class FMaximumMagTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
void testInfArg(FMaximumMagFunc func) {
EXPECT_FP_EQ(inf, func(neg_inf, inf));
- EXPECT_FP_EQ(inf, func(inf, 0.0));
- EXPECT_FP_EQ(inf, func(-0.0, inf));
+ EXPECT_FP_EQ(inf, func(inf, zero));
+ EXPECT_FP_EQ(inf, func(neg_zero, inf));
EXPECT_FP_EQ(inf, func(inf, T(1.2345)));
EXPECT_FP_EQ(inf, func(T(-1.2345), inf));
}
void testNegInfArg(FMaximumMagFunc func) {
EXPECT_FP_EQ(inf, func(inf, neg_inf));
- EXPECT_FP_EQ(neg_inf, func(neg_inf, 0.0));
- EXPECT_FP_EQ(neg_inf, func(-0.0, neg_inf));
+ EXPECT_FP_EQ(neg_inf, func(neg_inf, zero));
+ EXPECT_FP_EQ(neg_inf, func(neg_zero, neg_inf));
EXPECT_FP_EQ(neg_inf, func(neg_inf, T(-1.2345)));
EXPECT_FP_EQ(neg_inf, func(T(1.2345), neg_inf));
}
void testBothZero(FMaximumMagFunc func) {
- EXPECT_FP_EQ(0.0, func(0.0, 0.0));
- EXPECT_FP_EQ(0.0, func(-0.0, 0.0));
- EXPECT_FP_EQ(0.0, func(0.0, -0.0));
- EXPECT_FP_EQ(-0.0, func(-0.0, -0.0));
+ EXPECT_FP_EQ(zero, func(zero, zero));
+ EXPECT_FP_EQ(zero, func(neg_zero, zero));
+ EXPECT_FP_EQ(zero, func(zero, neg_zero));
+ EXPECT_FP_EQ(neg_zero, func(neg_zero, neg_zero));
}
void testRange(FMaximumMagFunc func) {
diff --git a/libc/test/src/math/smoke/FMaximumNumTest.h b/libc/test/src/math/smoke/FMaximumNumTest.h
index ec7913509d394..f4e05b9f455ed 100644
--- a/libc/test/src/math/smoke/FMaximumNumTest.h
+++ b/libc/test/src/math/smoke/FMaximumNumTest.h
@@ -29,10 +29,10 @@ class FMaximumNumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
EXPECT_FP_EQ(neg_inf, func(neg_inf, aNaN));
EXPECT_FP_EQ_WITH_EXCEPTION(neg_inf, func(neg_inf, sNaN), FE_INVALID);
EXPECT_EQ(FPBits(aNaN).uintval(), FPBits(func(aNaN, aNaN)).uintval());
- EXPECT_FP_EQ(0.0, func(aNaN, 0.0));
- EXPECT_FP_EQ(-0.0, func(-0.0, aNaN));
- EXPECT_FP_EQ_WITH_EXCEPTION(0.0, func(sNaN, 0.0), FE_INVALID);
- EXPECT_FP_EQ_WITH_EXCEPTION(-0.0, func(-0.0, sNaN), FE_INVALID);
+ EXPECT_FP_EQ(zero, func(aNaN, zero));
+ EXPECT_FP_EQ(neg_zero, func(neg_zero, aNaN));
+ EXPECT_FP_EQ_WITH_EXCEPTION(zero, func(sNaN, zero), FE_INVALID);
+ EXPECT_FP_EQ_WITH_EXCEPTION(neg_zero, func(neg_zero, sNaN), FE_INVALID);
EXPECT_FP_EQ(T(-1.2345), func(aNaN, T(-1.2345)));
EXPECT_FP_EQ(T(1.2345), func(T(1.2345), aNaN));
EXPECT_FP_EQ_WITH_EXCEPTION(T(-1.2345), func(sNaN, T(-1.2345)), FE_INVALID);
@@ -46,25 +46,25 @@ class FMaximumNumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
void testInfArg(FMaximumNumFunc func) {
EXPECT_FP_EQ(inf, func(neg_inf, inf));
- EXPECT_FP_EQ(inf, func(inf, 0.0));
- EXPECT_FP_EQ(inf, func(-0.0, inf));
+ EXPECT_FP_EQ(inf, func(inf, zero));
+ EXPECT_FP_EQ(inf, func(neg_zero, inf));
EXPECT_FP_EQ(inf, func(inf, T(1.2345)));
EXPECT_FP_EQ(inf, func(T(-1.2345), inf));
}
void testNegInfArg(FMaximumNumFunc func) {
EXPECT_FP_EQ(inf, func(inf, neg_inf));
- EXPECT_FP_EQ(0.0, func(neg_inf, 0.0));
- EXPECT_FP_EQ(-0.0, func(-0.0, neg_inf));
+ EXPECT_FP_EQ(zero, func(neg_inf, zero));
+ EXPECT_FP_EQ(neg_zero, func(neg_zero, neg_inf));
EXPECT_FP_EQ(T(-1.2345), func(neg_inf, T(-1.2345)));
EXPECT_FP_EQ(T(1.2345), func(T(1.2345), neg_inf));
}
void testBothZero(FMaximumNumFunc func) {
- EXPECT_FP_EQ(0.0, func(0.0, 0.0));
- EXPECT_FP_EQ(0.0, func(-0.0, 0.0));
- EXPECT_FP_EQ(0.0, func(0.0, -0.0));
- EXPECT_FP_EQ(-0.0, func(-0.0, -0.0));
+ EXPECT_FP_EQ(zero, func(zero, zero));
+ EXPECT_FP_EQ(zero, func(neg_zero, zero));
+ EXPECT_FP_EQ(zero, func(zero, neg_zero));
+ EXPECT_FP_EQ(neg_zero, func(neg_zero, neg_zero));
}
void testRange(FMaximumNumFunc func) {
diff --git a/libc/test/src/math/smoke/FMaximumTest.h b/libc/test/src/math/smoke/FMaximumTest.h
index 94e4a343190a5..5e71a41d7b345 100644
--- a/libc/test/src/math/smoke/FMaximumTest.h
+++ b/libc/test/src/math/smoke/FMaximumTest.h
@@ -25,8 +25,8 @@ class FMaximumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
void testNaN(FMaximumFunc func) {
EXPECT_FP_EQ(aNaN, func(aNaN, inf));
EXPECT_FP_EQ(aNaN, func(neg_inf, aNaN));
- EXPECT_FP_EQ(aNaN, func(aNaN, 0.0));
- EXPECT_FP_EQ(aNaN, func(-0.0, aNaN));
+ EXPECT_FP_EQ(aNaN, func(aNaN, zero));
+ EXPECT_FP_EQ(aNaN, func(neg_zero, aNaN));
EXPECT_FP_EQ(aNaN, func(aNaN, T(-1.2345)));
EXPECT_FP_EQ(aNaN, func(T(1.2345), aNaN));
EXPECT_FP_EQ(aNaN, func(aNaN, aNaN));
@@ -34,25 +34,25 @@ class FMaximumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
void testInfArg(FMaximumFunc func) {
EXPECT_FP_EQ(inf, func(neg_inf, inf));
- EXPECT_FP_EQ(inf, func(inf, 0.0));
- EXPECT_FP_EQ(inf, func(-0.0, inf));
+ EXPECT_FP_EQ(inf, func(inf, zero));
+ EXPECT_FP_EQ(inf, func(neg_zero, inf));
EXPECT_FP_EQ(inf, func(inf, T(1.2345)));
EXPECT_FP_EQ(inf, func(T(-1.2345), inf));
}
void testNegInfArg(FMaximumFunc func) {
EXPECT_FP_EQ(inf, func(inf, neg_inf));
- EXPECT_FP_EQ(0.0, func(neg_inf, 0.0));
- EXPECT_FP_EQ(-0.0, func(-0.0, neg_inf));
+ EXPECT_FP_EQ(zero, func(neg_inf, zero));
+ EXPECT_FP_EQ(neg_zero, func(neg_zero, neg_inf));
EXPECT_FP_EQ(T(-1.2345), func(neg_inf, T(-1.2345)));
EXPECT_FP_EQ(T(1.2345), func(T(1.2345), neg_inf));
}
void testBothZero(FMaximumFunc func) {
- EXPECT_FP_EQ(0.0, func(0.0, 0.0));
- EXPECT_FP_EQ(0.0, func(-0.0, 0.0));
- EXPECT_FP_EQ(0.0, func(0.0, -0.0));
- EXPECT_FP_EQ(-0.0, func(-0.0, -0.0));
+ EXPECT_FP_EQ(zero, func(zero, zero));
+ EXPECT_FP_EQ(zero, func(neg_zero, zero));
+ EXPECT_FP_EQ(zero, func(zero, neg_zero));
+ EXPECT_FP_EQ(neg_zero, func(neg_zero, neg_zero));
}
void testRange(FMaximumFunc func) {
diff --git a/libc/test/src/math/smoke/FMinTest.h b/libc/test/src/math/smoke/FMinTest.h
index 629aaab729a86..049d94eb1b340 100644
--- a/libc/test/src/math/smoke/FMinTest.h
+++ b/libc/test/src/math/smoke/FMinTest.h
@@ -25,8 +25,8 @@ class FMinTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
void testNaN(FMinFunc func) {
EXPECT_FP_EQ(inf, func(aNaN, inf));
EXPECT_FP_EQ(neg_inf, func(neg_inf, aNaN));
- EXPECT_FP_EQ(0.0, func(aNaN, 0.0));
- EXPECT_FP_EQ(-0.0, func(-0.0, aNaN));
+ EXPECT_FP_EQ(zero, func(aNaN, zero));
+ EXPECT_FP_EQ(neg_zero, func(neg_zero, aNaN));
EXPECT_FP_EQ(T(-1.2345), func(aNaN, T(-1.2345)));
EXPECT_FP_EQ(T(1.2345), func(T(1.2345), aNaN));
EXPECT_FP_EQ(aNaN, func(aNaN, aNaN));
@@ -34,25 +34,25 @@ class FMinTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
void testInfArg(FMinFunc func) {
EXPECT_FP_EQ(neg_inf, func(neg_inf, inf));
- EXPECT_FP_EQ(0.0, func(inf, 0.0));
- EXPECT_FP_EQ(-0.0, func(-0.0, inf));
+ EXPECT_FP_EQ(zero, func(inf, zero));
+ EXPECT_FP_EQ(neg_zero, func(neg_zero, inf));
EXPECT_FP_EQ(T(1.2345), func(inf, T(1.2345)));
EXPECT_FP_EQ(T(-1.2345), func(T(-1.2345), inf));
}
void testNegInfArg(FMinFunc func) {
EXPECT_FP_EQ(neg_inf, func(inf, neg_inf));
- EXPECT_FP_EQ(neg_inf, func(neg_inf, 0.0));
- EXPECT_FP_EQ(neg_inf, func(-0.0, neg_inf));
+ EXPECT_FP_EQ(neg_inf, func(neg_inf, zero));
+ EXPECT_FP_EQ(neg_inf, func(neg_zero, neg_inf));
EXPECT_FP_EQ(neg_inf, func(neg_inf, T(-1.2345)));
EXPECT_FP_EQ(neg_inf, func(T(1.2345), neg_inf));
}
void testBothZero(FMinFunc func) {
- EXPECT_FP_EQ(0.0, func(0.0, 0.0));
- EXPECT_FP_EQ(-0.0, func(-0.0, 0.0));
- EXPECT_FP_EQ(-0.0, func(0.0, -0.0));
- EXPECT_FP_EQ(-0.0, func(-0.0, -0.0));
+ EXPECT_FP_EQ(zero, func(zero, zero));
+ EXPECT_FP_EQ(neg_zero, func(neg_zero, zero));
+ EXPECT_FP_EQ(neg_zero, func(zero, neg_zero));
+ EXPECT_FP_EQ(neg_zero, func(neg_zero, neg_zero));
}
void testRange(FMinFunc func) {
diff --git a/libc/test/src/math/smoke/FMinimumMagNumTest.h b/libc/test/src/math/smoke/FMinimumMagNumTest.h
index 2ceca6ff95bac..4cec6f08b2daa 100644
--- a/libc/test/src/math/smoke/FMinimumMagNumTest.h
+++ b/libc/test/src/math/smoke/FMinimumMagNumTest.h
@@ -30,10 +30,10 @@ class FMinimumMagNumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
EXPECT_FP_EQ(neg_inf, func(neg_inf, aNaN));
EXPECT_FP_EQ_WITH_EXCEPTION(neg_inf, func(neg_inf, sNaN), FE_INVALID);
EXPECT_EQ(FPBits(aNaN).uintval(), FPBits(func(aNaN, aNaN)).uintval());
- EXPECT_FP_EQ(0.0, func(aNaN, 0.0));
- EXPECT_FP_EQ(-0.0, func(-0.0, aNaN));
- EXPECT_FP_EQ_WITH_EXCEPTION(0.0, func(sNaN, 0.0), FE_INVALID);
- EXPECT_FP_EQ_WITH_EXCEPTION(-0.0, func(-0.0, sNaN), FE_INVALID);
+ EXPECT_FP_EQ(zero, func(aNaN, zero));
+ EXPECT_FP_EQ(neg_zero, func(neg_zero, aNaN));
+ EXPECT_FP_EQ_WITH_EXCEPTION(zero, func(sNaN, zero), FE_INVALID);
+ EXPECT_FP_EQ_WITH_EXCEPTION(neg_zero, func(neg_zero, sNaN), FE_INVALID);
EXPECT_FP_EQ(T(-1.2345), func(aNaN, T(-1.2345)));
EXPECT_FP_EQ(T(1.2345), func(T(1.2345), aNaN));
EXPECT_FP_EQ_WITH_EXCEPTION(T(-1.2345), func(sNaN, T(-1.2345)), FE_INVALID);
@@ -47,25 +47,25 @@ class FMinimumMagNumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
void testInfArg(FMinimumMagNumFunc func) {
EXPECT_FP_EQ(neg_inf, func(neg_inf, inf));
- EXPECT_FP_EQ(0.0, func(inf, 0.0));
- EXPECT_FP_EQ(-0.0, func(-0.0, inf));
+ EXPECT_FP_EQ(zero, func(inf, zero));
+ EXPECT_FP_EQ(neg_zero, func(neg_zero, inf));
EXPECT_FP_EQ(T(1.2345), func(inf, T(1.2345)));
EXPECT_FP_EQ(T(-1.2345), func(T(-1.2345), inf));
}
void testNegInfArg(FMinimumMagNumFunc func) {
EXPECT_FP_EQ(neg_inf, func(inf, neg_inf));
- EXPECT_FP_EQ(0.0, func(neg_inf, 0.0));
- EXPECT_FP_EQ(-0.0, func(-0.0, neg_inf));
+ EXPECT_FP_EQ(zero, func(neg_inf, zero));
+ EXPECT_FP_EQ(neg_zero, func(neg_zero, neg_inf));
EXPECT_FP_EQ(T(-1.2345), func(neg_inf, T(-1.2345)));
EXPECT_FP_EQ(T(1.2345), func(T(1.2345), neg_inf));
}
void testBothZero(FMinimumMagNumFunc func) {
- EXPECT_FP_EQ(0.0, func(0.0, 0.0));
- EXPECT_FP_EQ(-0.0, func(-0.0, 0.0));
- EXPECT_FP_EQ(-0.0, func(0.0, -0.0));
- EXPECT_FP_EQ(-0.0, func(-0.0, -0.0));
+ EXPECT_FP_EQ(zero, func(zero, zero));
+ EXPECT_FP_EQ(neg_zero, func(neg_zero, zero));
+ EXPECT_FP_EQ(neg_zero, func(zero, neg_zero));
+ EXPECT_FP_EQ(neg_zero, func(neg_zero, neg_zero));
}
void testRange(FMinimumMagNumFunc func) {
diff --git a/libc/test/src/math/smoke/FMinimumMagTest.h b/libc/test/src/math/smoke/FMinimumMagTest.h
index 9c49446795cee..18b43815bdeca 100644
--- a/libc/test/src/math/smoke/FMinimumMagTest.h
+++ b/libc/test/src/math/smoke/FMinimumMagTest.h
@@ -26,8 +26,8 @@ class FMinimumMagTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
void testNaN(FMinimumMagFunc func) {
EXPECT_FP_EQ(aNaN, func(aNaN, inf));
EXPECT_FP_EQ(aNaN, func(neg_inf, aNaN));
- EXPECT_FP_EQ(aNaN, func(aNaN, 0.0));
- EXPECT_FP_EQ(aNaN, func(-0.0, aNaN));
+ EXPECT_FP_EQ(aNaN, func(aNaN, zero));
+ EXPECT_FP_EQ(aNaN, func(neg_zero, aNaN));
EXPECT_FP_EQ(aNaN, func(aNaN, T(-1.2345)));
EXPECT_FP_EQ(aNaN, func(T(1.2345), aNaN));
EXPECT_FP_EQ(aNaN, func(aNaN, aNaN));
@@ -35,25 +35,25 @@ class FMinimumMagTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
void testInfArg(FMinimumMagFunc func) {
EXPECT_FP_EQ(neg_inf, func(neg_inf, inf));
- EXPECT_FP_EQ(0.0, func(inf, 0.0));
- EXPECT_FP_EQ(-0.0, func(-0.0, inf));
+ EXPECT_FP_EQ(zero, func(inf, zero));
+ EXPECT_FP_EQ(neg_zero, func(neg_zero, inf));
EXPECT_FP_EQ(T(1.2345), func(inf, T(1.2345)));
EXPECT_FP_EQ(T(-1.2345), func(T(-1.2345), inf));
}
void testNegInfArg(FMinimumMagFunc func) {
EXPECT_FP_EQ(neg_inf, func(inf, neg_inf));
- EXPECT_FP_EQ(0.0, func(neg_inf, 0.0));
- EXPECT_FP_EQ(-0.0, func(-0.0, neg_inf));
+ EXPECT_FP_EQ(zero, func(neg_inf, zero));
+ EXPECT_FP_EQ(neg_zero, func(neg_zero, neg_inf));
EXPECT_FP_EQ(T(-1.2345), func(neg_inf, T(-1.2345)));
EXPECT_FP_EQ(T(1.2345), func(T(1.2345), neg_inf));
}
void testBothZero(FMinimumMagFunc func) {
- EXPECT_FP_EQ(0.0, func(0.0, 0.0));
- EXPECT_FP_EQ(-0.0, func(-0.0, 0.0));
- EXPECT_FP_EQ(-0.0, func(0.0, -0.0));
- EXPECT_FP_EQ(-0.0, func(-0.0, -0.0));
+ EXPECT_FP_EQ(zero, func(zero, zero));
+ EXPECT_FP_EQ(neg_zero, func(neg_zero, zero));
+ EXPECT_FP_EQ(neg_zero, func(zero, neg_zero));
+ EXPECT_FP_EQ(neg_zero, func(neg_zero, neg_zero));
}
void testRange(FMinimumMagFunc func) {
diff --git a/libc/test/src/math/smoke/FMinimumNumTest.h b/libc/test/src/math/smoke/FMinimumNumTest.h
index 8004ee9874543..dddcdc28d30c8 100644
--- a/libc/test/src/math/smoke/FMinimumNumTest.h
+++ b/libc/test/src/math/smoke/FMinimumNumTest.h
@@ -29,10 +29,10 @@ class FMinimumNumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
EXPECT_FP_EQ(neg_inf, func(neg_inf, aNaN));
EXPECT_FP_EQ_WITH_EXCEPTION(neg_inf, func(neg_inf, sNaN), FE_INVALID);
EXPECT_EQ(FPBits(aNaN).uintval(), FPBits(func(aNaN, aNaN)).uintval());
- EXPECT_FP_EQ(0.0, func(aNaN, 0.0));
- EXPECT_FP_EQ(-0.0, func(-0.0, aNaN));
- EXPECT_FP_EQ_WITH_EXCEPTION(0.0, func(sNaN, 0.0), FE_INVALID);
- EXPECT_FP_EQ_WITH_EXCEPTION(-0.0, func(-0.0, sNaN), FE_INVALID);
+ EXPECT_FP_EQ(zero, func(aNaN, zero));
+ EXPECT_FP_EQ(neg_zero, func(neg_zero, aNaN));
+ EXPECT_FP_EQ_WITH_EXCEPTION(zero, func(sNaN, zero), FE_INVALID);
+ EXPECT_FP_EQ_WITH_EXCEPTION(neg_zero, func(neg_zero, sNaN), FE_INVALID);
EXPECT_FP_EQ(T(-1.2345), func(aNaN, T(-1.2345)));
EXPECT_FP_EQ(T(1.2345), func(T(1.2345), aNaN));
EXPECT_FP_EQ_WITH_EXCEPTION(T(-1.2345), func(sNaN, T(-1.2345)), FE_INVALID);
@@ -46,25 +46,25 @@ class FMinimumNumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
void testInfArg(FMinimumNumFunc func) {
EXPECT_FP_EQ(neg_inf, func(neg_inf, inf));
- EXPECT_FP_EQ(0.0, func(inf, 0.0));
- EXPECT_FP_EQ(-0.0, func(-0.0, inf));
+ EXPECT_FP_EQ(zero, func(inf, zero));
+ EXPECT_FP_EQ(neg_zero, func(neg_zero, inf));
EXPECT_FP_EQ(T(1.2345), func(inf, T(1.2345)));
EXPECT_FP_EQ(T(-1.2345), func(T(-1.2345), inf));
}
void testNegInfArg(FMinimumNumFunc func) {
EXPECT_FP_EQ(neg_inf, func(inf, neg_inf));
- EXPECT_FP_EQ(neg_inf, func(neg_inf, 0.0));
- EXPECT_FP_EQ(neg_inf, func(-0.0, neg_inf));
+ EXPECT_FP_EQ(neg_inf, func(neg_inf, zero));
+ EXPECT_FP_EQ(neg_inf, func(neg_zero, neg_inf));
EXPECT_FP_EQ(neg_inf, func(neg_inf, T(-1.2345)));
EXPECT_FP_EQ(neg_inf, func(T(1.2345), neg_inf));
}
void testBothZero(FMinimumNumFunc func) {
- EXPECT_FP_EQ(0.0, func(0.0, 0.0));
- EXPECT_FP_EQ(-0.0, func(-0.0, 0.0));
- EXPECT_FP_EQ(-0.0, func(0.0, -0.0));
- EXPECT_FP_EQ(-0.0, func(-0.0, -0.0));
+ EXPECT_FP_EQ(zero, func(zero, zero));
+ EXPECT_FP_EQ(neg_zero, func(neg_zero, zero));
+ EXPECT_FP_EQ(neg_zero, func(zero, neg_zero));
+ EXPECT_FP_EQ(neg_zero, func(neg_zero, neg_zero));
}
void testRange(FMinimumNumFunc func) {
diff --git a/libc/test/src/math/smoke/FMinimumTest.h b/libc/test/src/math/smoke/FMinimumTest.h
index 242c857fbb99b..b5c0e98d17b99 100644
--- a/libc/test/src/math/smoke/FMinimumTest.h
+++ b/libc/test/src/math/smoke/FMinimumTest.h
@@ -25,8 +25,8 @@ class FMinimumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
void testNaN(FMinimumFunc func) {
EXPECT_FP_EQ(aNaN, func(aNaN, inf));
EXPECT_FP_EQ(aNaN, func(neg_inf, aNaN));
- EXPECT_FP_EQ(aNaN, func(aNaN, 0.0));
- EXPECT_FP_EQ(aNaN, func(-0.0, aNaN));
+ EXPECT_FP_EQ(aNaN, func(aNaN, zero));
+ EXPECT_FP_EQ(aNaN, func(neg_zero, aNaN));
EXPECT_FP_EQ(aNaN, func(aNaN, T(-1.2345)));
EXPECT_FP_EQ(aNaN, func(T(1.2345), aNaN));
EXPECT_FP_EQ(aNaN, func(aNaN, aNaN));
@@ -34,25 +34,25 @@ class FMinimumTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
void testInfArg(FMinimumFunc func) {
EXPECT_FP_EQ(neg_inf, func(neg_inf, inf));
- EXPECT_FP_EQ(0.0, func(inf, 0.0));
- EXPECT_FP_EQ(-0.0, func(-0.0, inf));
+ EXPECT_FP_EQ(zero, func(inf, zero));
+ EXPECT_FP_EQ(neg_zero, func(neg_zero, inf));
EXPECT_FP_EQ(T(1.2345), func(inf, T(1.2345)));
EXPECT_FP_EQ(T(1.2345), func(T(1.2345), inf));
}
void testNegInfArg(FMinimumFunc func) {
EXPECT_FP_EQ(neg_inf, func(inf, neg_inf));
- EXPECT_FP_EQ(neg_inf, func(neg_inf, 0.0));
- EXPECT_FP_EQ(neg_inf, func(-0.0, neg_inf));
+ EXPECT_FP_EQ(neg_inf, func(neg_inf, zero));
+ EXPECT_FP_EQ(neg_inf, func(neg_zero, neg_inf));
EXPECT_FP_EQ(neg_inf, func(neg_inf, T(-1.2345)));
EXPECT_FP_EQ(neg_inf, func(T(1.2345), neg_inf));
}
void testBothZero(FMinimumFunc func) {
- EXPECT_FP_EQ(0.0, func(0.0, 0.0));
- EXPECT_FP_EQ(-0.0, func(-0.0, 0.0));
- EXPECT_FP_EQ(-0.0, func(0.0, -0.0));
- EXPECT_FP_EQ(-0.0, func(-0.0, -0.0));
+ EXPECT_FP_EQ(zero, func(zero, zero));
+ EXPECT_FP_EQ(neg_zero, func(neg_zero, zero));
+ EXPECT_FP_EQ(neg_zero, func(zero, neg_zero));
+ EXPECT_FP_EQ(neg_zero, func(neg_zero, neg_zero));
}
void testRange(FMinimumFunc func) {
diff --git a/libc/test/src/math/smoke/FModTest.h b/libc/test/src/math/smoke/FModTest.h
index 405e3107438d4..0a4227da83f81 100644
--- a/libc/test/src/math/smoke/FModTest.h
+++ b/libc/test/src/math/smoke/FModTest.h
@@ -35,16 +35,16 @@ class FmodTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
void testSpecialNumbers(FModFunc f) {
// fmod (+0, y) == +0 for y != 0.
- TEST_SPECIAL(0.0, 3.0, 0.0, false, 0);
- TEST_SPECIAL(0.0, min_denormal, 0.0, false, 0);
- TEST_SPECIAL(0.0, -min_denormal, 0.0, false, 0);
- TEST_SPECIAL(0.0, min_normal, 0.0, false, 0);
- TEST_SPECIAL(0.0, -min_normal, 0.0, false, 0);
- TEST_SPECIAL(0.0, max_normal, 0.0, false, 0);
- TEST_SPECIAL(0.0, -max_normal, 0.0, false, 0);
+ TEST_SPECIAL(zero, T(3.0), zero, false, 0);
+ TEST_SPECIAL(zero, min_denormal, zero, false, 0);
+ TEST_SPECIAL(zero, -min_denormal, zero, false, 0);
+ TEST_SPECIAL(zero, min_normal, zero, false, 0);
+ TEST_SPECIAL(zero, -min_normal, zero, false, 0);
+ TEST_SPECIAL(zero, max_normal, zero, false, 0);
+ TEST_SPECIAL(zero, -max_normal, zero, false, 0);
// fmod (-0, y) == -0 for y != 0.
- TEST_SPECIAL(neg_zero, 3.0, neg_zero, false, 0);
+ TEST_SPECIAL(neg_zero, T(3.0), neg_zero, false, 0);
TEST_SPECIAL(neg_zero, min_denormal, neg_zero, false, 0);
TEST_SPECIAL(neg_zero, -min_denormal, neg_zero, false, 0);
TEST_SPECIAL(neg_zero, min_normal, neg_zero, false, 0);
@@ -53,9 +53,9 @@ class FmodTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
TEST_SPECIAL(neg_zero, -max_normal, neg_zero, false, 0);
// fmod (+inf, y) == aNaN plus invalid exception.
- TEST_SPECIAL(inf, 3.0, aNaN, true, FE_INVALID);
- TEST_SPECIAL(inf, -1.1L, aNaN, true, FE_INVALID);
- TEST_SPECIAL(inf, 0.0, aNaN, true, FE_INVALID);
+ TEST_SPECIAL(inf, T(3.0), aNaN, true, FE_INVALID);
+ TEST_SPECIAL(inf, T(-1.1), aNaN, true, FE_INVALID);
+ TEST_SPECIAL(inf, zero, aNaN, true, FE_INVALID);
TEST_SPECIAL(inf, neg_zero, aNaN, true, FE_INVALID);
TEST_SPECIAL(inf, min_denormal, aNaN, true, FE_INVALID);
TEST_SPECIAL(inf, min_normal, aNaN, true, FE_INVALID);
@@ -64,9 +64,9 @@ class FmodTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
TEST_SPECIAL(inf, neg_inf, aNaN, true, FE_INVALID);
// fmod (-inf, y) == aNaN plus invalid exception.
- TEST_SPECIAL(neg_inf, 3.0, aNaN, true, FE_INVALID);
- TEST_SPECIAL(neg_inf, -1.1L, aNaN, true, FE_INVALID);
- TEST_SPECIAL(neg_inf, 0.0, aNaN, true, FE_INVALID);
+ TEST_SPECIAL(neg_inf, T(3.0), aNaN, true, FE_INVALID);
+ TEST_SPECIAL(neg_inf, T(-1.1), aNaN, true, FE_INVALID);
+ TEST_SPECIAL(neg_inf, zero, aNaN, true, FE_INVALID);
TEST_SPECIAL(neg_inf, neg_zero, aNaN, true, FE_INVALID);
TEST_SPECIAL(neg_inf, min_denormal, aNaN, true, FE_INVALID);
TEST_SPECIAL(neg_inf, min_normal, aNaN, true, FE_INVALID);
@@ -75,74 +75,74 @@ class FmodTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
TEST_SPECIAL(neg_inf, neg_inf, aNaN, true, FE_INVALID);
// fmod (x, +0) == aNaN plus invalid exception.
- TEST_SPECIAL(3.0, 0.0, aNaN, true, FE_INVALID);
- TEST_SPECIAL(-1.1L, 0.0, aNaN, true, FE_INVALID);
- TEST_SPECIAL(0.0, 0.0, aNaN, true, FE_INVALID);
- TEST_SPECIAL(neg_zero, 0.0, aNaN, true, FE_INVALID);
- TEST_SPECIAL(min_denormal, 0.0, aNaN, true, FE_INVALID);
- TEST_SPECIAL(min_normal, 0.0, aNaN, true, FE_INVALID);
- TEST_SPECIAL(max_normal, 0.0, aNaN, true, FE_INVALID);
+ TEST_SPECIAL(T(3.0), zero, aNaN, true, FE_INVALID);
+ TEST_SPECIAL(T(-1.1), zero, aNaN, true, FE_INVALID);
+ TEST_SPECIAL(zero, zero, aNaN, true, FE_INVALID);
+ TEST_SPECIAL(neg_zero, zero, aNaN, true, FE_INVALID);
+ TEST_SPECIAL(min_denormal, zero, aNaN, true, FE_INVALID);
+ TEST_SPECIAL(min_normal, zero, aNaN, true, FE_INVALID);
+ TEST_SPECIAL(max_normal, zero, aNaN, true, FE_INVALID);
// fmod (x, -0) == aNaN plus invalid exception.
- TEST_SPECIAL(3.0, neg_zero, aNaN, true, FE_INVALID);
- TEST_SPECIAL(-1.1L, neg_zero, aNaN, true, FE_INVALID);
- TEST_SPECIAL(0.0, neg_zero, aNaN, true, FE_INVALID);
+ TEST_SPECIAL(T(3.0), neg_zero, aNaN, true, FE_INVALID);
+ TEST_SPECIAL(T(-1.1), neg_zero, aNaN, true, FE_INVALID);
+ TEST_SPECIAL(zero, neg_zero, aNaN, true, FE_INVALID);
TEST_SPECIAL(neg_zero, neg_zero, aNaN, true, FE_INVALID);
TEST_SPECIAL(min_denormal, neg_zero, aNaN, true, FE_INVALID);
TEST_SPECIAL(min_normal, neg_zero, aNaN, true, FE_INVALID);
TEST_SPECIAL(max_normal, neg_zero, aNaN, true, FE_INVALID);
// fmod (x, +inf) == x for x not infinite.
- TEST_SPECIAL(0.0, inf, 0.0, false, 0);
+ TEST_SPECIAL(zero, inf, zero, false, 0);
TEST_SPECIAL(neg_zero, inf, neg_zero, false, 0);
TEST_SPECIAL(min_denormal, inf, min_denormal, false, 0);
TEST_SPECIAL(min_normal, inf, min_normal, false, 0);
TEST_SPECIAL(max_normal, inf, max_normal, false, 0);
- TEST_SPECIAL(3.0, inf, 3.0, false, 0);
+ TEST_SPECIAL(T(3.0), inf, T(3.0), false, 0);
// fmod (x, -inf) == x for x not infinite.
- TEST_SPECIAL(0.0, neg_inf, 0.0, false, 0);
+ TEST_SPECIAL(zero, neg_inf, zero, false, 0);
TEST_SPECIAL(neg_zero, neg_inf, neg_zero, false, 0);
TEST_SPECIAL(min_denormal, neg_inf, min_denormal, false, 0);
TEST_SPECIAL(min_normal, neg_inf, min_normal, false, 0);
TEST_SPECIAL(max_normal, neg_inf, max_normal, false, 0);
- TEST_SPECIAL(3.0, neg_inf, 3.0, false, 0);
+ TEST_SPECIAL(T(3.0), neg_inf, T(3.0), false, 0);
- TEST_SPECIAL(0.0, aNaN, aNaN, false, 0);
- TEST_SPECIAL(0.0, -aNaN, aNaN, false, 0);
+ TEST_SPECIAL(zero, aNaN, aNaN, false, 0);
+ TEST_SPECIAL(zero, -aNaN, aNaN, false, 0);
TEST_SPECIAL(neg_zero, aNaN, aNaN, false, 0);
TEST_SPECIAL(neg_zero, -aNaN, aNaN, false, 0);
- TEST_SPECIAL(1.0, aNaN, aNaN, false, 0);
- TEST_SPECIAL(1.0, -aNaN, aNaN, false, 0);
+ TEST_SPECIAL(T(1.0), aNaN, aNaN, false, 0);
+ TEST_SPECIAL(T(1.0), -aNaN, aNaN, false, 0);
TEST_SPECIAL(inf, aNaN, aNaN, false, 0);
TEST_SPECIAL(inf, -aNaN, aNaN, false, 0);
TEST_SPECIAL(neg_inf, aNaN, aNaN, false, 0);
TEST_SPECIAL(neg_inf, -aNaN, aNaN, false, 0);
- TEST_SPECIAL(0.0, sNaN, aNaN, false, FE_INVALID);
- TEST_SPECIAL(0.0, -sNaN, aNaN, false, FE_INVALID);
+ TEST_SPECIAL(zero, sNaN, aNaN, false, FE_INVALID);
+ TEST_SPECIAL(zero, -sNaN, aNaN, false, FE_INVALID);
TEST_SPECIAL(neg_zero, sNaN, aNaN, false, FE_INVALID);
TEST_SPECIAL(neg_zero, -sNaN, aNaN, false, FE_INVALID);
- TEST_SPECIAL(1.0, sNaN, aNaN, false, FE_INVALID);
- TEST_SPECIAL(1.0, -sNaN, aNaN, false, FE_INVALID);
+ TEST_SPECIAL(T(1.0), sNaN, aNaN, false, FE_INVALID);
+ TEST_SPECIAL(T(1.0), -sNaN, aNaN, false, FE_INVALID);
TEST_SPECIAL(inf, sNaN, aNaN, false, FE_INVALID);
TEST_SPECIAL(inf, -sNaN, aNaN, false, FE_INVALID);
TEST_SPECIAL(neg_inf, sNaN, aNaN, false, FE_INVALID);
TEST_SPECIAL(neg_inf, -sNaN, aNaN, false, FE_INVALID);
- TEST_SPECIAL(aNaN, 0.0, aNaN, false, 0);
- TEST_SPECIAL(-aNaN, 0.0, aNaN, false, 0);
+ TEST_SPECIAL(aNaN, zero, aNaN, false, 0);
+ TEST_SPECIAL(-aNaN, zero, aNaN, false, 0);
TEST_SPECIAL(aNaN, neg_zero, aNaN, false, 0);
TEST_SPECIAL(-aNaN, neg_zero, aNaN, false, 0);
- TEST_SPECIAL(aNaN, 1.0, aNaN, false, 0);
- TEST_SPECIAL(-aNaN, 1.0, aNaN, false, 0);
+ TEST_SPECIAL(aNaN, T(1.0), aNaN, false, 0);
+ TEST_SPECIAL(-aNaN, T(1.0), aNaN, false, 0);
TEST_SPECIAL(aNaN, inf, aNaN, false, 0);
TEST_SPECIAL(-aNaN, inf, aNaN, false, 0);
TEST_SPECIAL(aNaN, neg_inf, aNaN, false, 0);
TEST_SPECIAL(-aNaN, neg_inf, aNaN, false, 0);
- TEST_SPECIAL(sNaN, 0.0, aNaN, false, FE_INVALID);
- TEST_SPECIAL(-sNaN, 0.0, aNaN, false, FE_INVALID);
+ TEST_SPECIAL(sNaN, zero, aNaN, false, FE_INVALID);
+ TEST_SPECIAL(-sNaN, zero, aNaN, false, FE_INVALID);
TEST_SPECIAL(sNaN, neg_zero, aNaN, false, FE_INVALID);
TEST_SPECIAL(-sNaN, neg_zero, aNaN, false, FE_INVALID);
- TEST_SPECIAL(sNaN, 1.0, aNaN, false, FE_INVALID);
- TEST_SPECIAL(-sNaN, 1.0, aNaN, false, FE_INVALID);
+ TEST_SPECIAL(sNaN, T(1.0), aNaN, false, FE_INVALID);
+ TEST_SPECIAL(-sNaN, T(1.0), aNaN, false, FE_INVALID);
TEST_SPECIAL(sNaN, inf, aNaN, false, FE_INVALID);
TEST_SPECIAL(-sNaN, inf, aNaN, false, FE_INVALID);
TEST_SPECIAL(sNaN, neg_inf, aNaN, false, FE_INVALID);
@@ -164,17 +164,17 @@ class FmodTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
TEST_SPECIAL(-sNaN, sNaN, aNaN, false, FE_INVALID);
TEST_SPECIAL(-sNaN, -sNaN, aNaN, false, FE_INVALID);
- TEST_SPECIAL(6.5, 2.25L, 2.0L, false, 0);
- TEST_SPECIAL(-6.5, 2.25L, -2.0L, false, 0);
- TEST_SPECIAL(6.5, -2.25L, 2.0L, false, 0);
- TEST_SPECIAL(-6.5, -2.25L, -2.0L, false, 0);
-
- TEST_SPECIAL(max_normal, max_normal, 0.0, false, 0);
- TEST_SPECIAL(max_normal, -max_normal, 0.0, false, 0);
- TEST_SPECIAL(max_normal, min_normal, 0.0, false, 0);
- TEST_SPECIAL(max_normal, -min_normal, 0.0, false, 0);
- TEST_SPECIAL(max_normal, min_denormal, 0.0, false, 0);
- TEST_SPECIAL(max_normal, -min_denormal, 0.0, false, 0);
+ TEST_SPECIAL(T(6.5), T(2.25), T(2.0), false, 0);
+ TEST_SPECIAL(T(-6.5), T(2.25), T(-2.0), false, 0);
+ TEST_SPECIAL(T(6.5), T(-2.25), T(2.0), false, 0);
+ TEST_SPECIAL(T(-6.5), T(-2.25), T(-2.0), false, 0);
+
+ TEST_SPECIAL(max_normal, max_normal, zero, false, 0);
+ TEST_SPECIAL(max_normal, -max_normal, zero, false, 0);
+ TEST_SPECIAL(max_normal, min_normal, zero, false, 0);
+ TEST_SPECIAL(max_normal, -min_normal, zero, false, 0);
+ TEST_SPECIAL(max_normal, min_denormal, zero, false, 0);
+ TEST_SPECIAL(max_normal, -min_denormal, zero, false, 0);
TEST_SPECIAL(-max_normal, max_normal, neg_zero, false, 0);
TEST_SPECIAL(-max_normal, -max_normal, neg_zero, false, 0);
TEST_SPECIAL(-max_normal, min_normal, neg_zero, false, 0);
@@ -184,10 +184,10 @@ class FmodTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
TEST_SPECIAL(min_normal, max_normal, min_normal, false, 0);
TEST_SPECIAL(min_normal, -max_normal, min_normal, false, 0);
- TEST_SPECIAL(min_normal, min_normal, 0.0, false, 0);
- TEST_SPECIAL(min_normal, -min_normal, 0.0, false, 0);
- TEST_SPECIAL(min_normal, min_denormal, 0.0, false, 0);
- TEST_SPECIAL(min_normal, -min_denormal, 0.0, false, 0);
+ TEST_SPECIAL(min_normal, min_normal, zero, false, 0);
+ TEST_SPECIAL(min_normal, -min_normal, zero, false, 0);
+ TEST_SPECIAL(min_normal, min_denormal, zero, false, 0);
+ TEST_SPECIAL(min_normal, -min_denormal, zero, false, 0);
TEST_SPECIAL(-min_normal, max_normal, -min_normal, false, 0);
TEST_SPECIAL(-min_normal, -max_normal, -min_normal, false, 0);
TEST_SPECIAL(-min_normal, min_normal, neg_zero, false, 0);
@@ -199,8 +199,8 @@ class FmodTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
TEST_SPECIAL(min_denormal, -max_normal, min_denormal, false, 0);
TEST_SPECIAL(min_denormal, min_normal, min_denormal, false, 0);
TEST_SPECIAL(min_denormal, -min_normal, min_denormal, false, 0);
- TEST_SPECIAL(min_denormal, min_denormal, 0.0, false, 0);
- TEST_SPECIAL(min_denormal, -min_denormal, 0.0, false, 0);
+ TEST_SPECIAL(min_denormal, min_denormal, zero, false, 0);
+ TEST_SPECIAL(min_denormal, -min_denormal, zero, false, 0);
TEST_SPECIAL(-min_denormal, max_normal, -min_denormal, false, 0);
TEST_SPECIAL(-min_denormal, -max_normal, -min_denormal, false, 0);
TEST_SPECIAL(-min_denormal, min_normal, -min_denormal, false, 0);
@@ -212,33 +212,33 @@ class FmodTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
void testRegularExtreme(FModFunc f) {
if constexpr (sizeof(T) < sizeof(float))
return;
- TEST_REGULAR(0x1p127L, 0x3p-149L, 0x1p-149L);
- TEST_REGULAR(0x1p127L, -0x3p-149L, 0x1p-149L);
- TEST_REGULAR(0x1p127L, 0x3p-148L, 0x1p-147L);
- TEST_REGULAR(0x1p127L, -0x3p-148L, 0x1p-147L);
- TEST_REGULAR(0x1p127L, 0x3p-126L, 0x1p-125L);
- TEST_REGULAR(0x1p127L, -0x3p-126L, 0x1p-125L);
- TEST_REGULAR(-0x1p127L, 0x3p-149L, -0x1p-149L);
- TEST_REGULAR(-0x1p127L, -0x3p-149L, -0x1p-149L);
- TEST_REGULAR(-0x1p127L, 0x3p-148L, -0x1p-147L);
- TEST_REGULAR(-0x1p127L, -0x3p-148L, -0x1p-147L);
- TEST_REGULAR(-0x1p127L, 0x3p-126L, -0x1p-125L);
- TEST_REGULAR(-0x1p127L, -0x3p-126L, -0x1p-125L);
+ TEST_REGULAR(T(0x1p127), T(0x3p-149), T(0x1p-149));
+ TEST_REGULAR(T(0x1p127), T(-0x3p-149), T(0x1p-149));
+ TEST_REGULAR(T(0x1p127), T(0x3p-148), T(0x1p-147));
+ TEST_REGULAR(T(0x1p127), T(-0x3p-148), T(0x1p-147));
+ TEST_REGULAR(T(0x1p127), T(0x3p-126), T(0x1p-125));
+ TEST_REGULAR(T(0x1p127), T(-0x3p-126), T(0x1p-125));
+ TEST_REGULAR(T(-0x1p127), T(0x3p-149), T(-0x1p-149));
+ TEST_REGULAR(T(-0x1p127), T(-0x3p-149), T(-0x1p-149));
+ TEST_REGULAR(T(-0x1p127), T(0x3p-148), T(-0x1p-147));
+ TEST_REGULAR(T(-0x1p127), T(-0x3p-148), T(-0x1p-147));
+ TEST_REGULAR(T(-0x1p127), T(0x3p-126), T(-0x1p-125));
+ TEST_REGULAR(T(-0x1p127), T(-0x3p-126), T(-0x1p-125));
if constexpr (sizeof(T) < sizeof(double))
return;
- TEST_REGULAR(0x1p1023L, 0x3p-1074L, 0x1p-1073L);
- TEST_REGULAR(0x1p1023L, -0x3p-1074L, 0x1p-1073L);
- TEST_REGULAR(0x1p1023L, 0x3p-1073L, 0x1p-1073L);
- TEST_REGULAR(0x1p1023L, -0x3p-1073L, 0x1p-1073L);
- TEST_REGULAR(0x1p1023L, 0x3p-1022L, 0x1p-1021L);
- TEST_REGULAR(0x1p1023L, -0x3p-1022L, 0x1p-1021L);
- TEST_REGULAR(-0x1p1023L, 0x3p-1074L, -0x1p-1073L);
- TEST_REGULAR(-0x1p1023L, -0x3p-1074L, -0x1p-1073L);
- TEST_REGULAR(-0x1p1023L, 0x3p-1073L, -0x1p-1073L);
- TEST_REGULAR(-0x1p1023L, -0x3p-1073L, -0x1p-1073L);
- TEST_REGULAR(-0x1p1023L, 0x3p-1022L, -0x1p-1021L);
- TEST_REGULAR(-0x1p1023L, -0x3p-1022L, -0x1p-1021L);
+ TEST_REGULAR(T(0x1p1023), T(0x3p-1074), T(0x1p-1073));
+ TEST_REGULAR(T(0x1p1023), T(-0x3p-1074), T(0x1p-1073));
+ TEST_REGULAR(T(0x1p1023), T(0x3p-1073), T(0x1p-1073));
+ TEST_REGULAR(T(0x1p1023), T(-0x3p-1073), T(0x1p-1073));
+ TEST_REGULAR(T(0x1p1023), T(0x3p-1022), T(0x1p-1021));
+ TEST_REGULAR(T(0x1p1023), T(-0x3p-1022), T(0x1p-1021));
+ TEST_REGULAR(T(-0x1p1023), T(0x3p-1074), T(-0x1p-1073));
+ TEST_REGULAR(T(-0x1p1023), T(-0x3p-1074), T(-0x1p-1073));
+ TEST_REGULAR(T(-0x1p1023), T(0x3p-1073), T(-0x1p-1073));
+ TEST_REGULAR(T(-0x1p1023), T(-0x3p-1073), T(-0x1p-1073));
+ TEST_REGULAR(T(-0x1p1023), T(0x3p-1022), T(-0x1p-1021));
+ TEST_REGULAR(T(-0x1p1023), T(-0x3p-1022), T(-0x1p-1021));
}
};
diff --git a/libc/test/src/math/smoke/FrexpTest.h b/libc/test/src/math/smoke/FrexpTest.h
index fc2313a94ef09..11641fc6743c4 100644
--- a/libc/test/src/math/smoke/FrexpTest.h
+++ b/libc/test/src/math/smoke/FrexpTest.h
@@ -24,10 +24,10 @@ class FrexpTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
EXPECT_FP_EQ_ALL_ROUNDING(inf, func(inf, &exponent));
EXPECT_FP_EQ_ALL_ROUNDING(neg_inf, func(neg_inf, &exponent));
- EXPECT_FP_EQ_ALL_ROUNDING(0.0, func(0.0, &exponent));
+ EXPECT_FP_EQ_ALL_ROUNDING(zero, func(zero, &exponent));
EXPECT_EQ(exponent, 0);
- EXPECT_FP_EQ_ALL_ROUNDING(-0.0, func(-0.0, &exponent));
+ EXPECT_FP_EQ_ALL_ROUNDING(-zero, func(-zero, &exponent));
EXPECT_EQ(exponent, 0);
}
diff --git a/libc/test/src/math/smoke/ILogbTest.h b/libc/test/src/math/smoke/ILogbTest.h
index 3315ac2cbbc64..988f71f54bf0d 100644
--- a/libc/test/src/math/smoke/ILogbTest.h
+++ b/libc/test/src/math/smoke/ILogbTest.h
@@ -47,13 +47,13 @@ class LlvmLibcILogbTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
EXPECT_EQ(OutType(2), func(InType(-4.0)));
EXPECT_EQ(OutType(3), func(InType(8.0)));
- EXPECT_EQ(OutType(3), func(-8.0));
+ EXPECT_EQ(OutType(3), func(InType(-8.0)));
- EXPECT_EQ(OutType(4), func(16.0));
- EXPECT_EQ(OutType(4), func(-16.0));
+ EXPECT_EQ(OutType(4), func(InType(16.0)));
+ EXPECT_EQ(OutType(4), func(InType(-16.0)));
- EXPECT_EQ(OutType(5), func(32.0));
- EXPECT_EQ(OutType(5), func(-32.0));
+ EXPECT_EQ(OutType(5), func(InType(32.0)));
+ EXPECT_EQ(OutType(5), func(InType(-32.0)));
}
void test_some_integers(Func func) {
@@ -67,10 +67,10 @@ class LlvmLibcILogbTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
EXPECT_EQ(OutType(3), func(InType(-10.0)));
EXPECT_EQ(OutType(4), func(InType(31.0)));
- EXPECT_EQ(OutType(4), func(-31.0));
+ EXPECT_EQ(OutType(4), func(InType(-31.0)));
- EXPECT_EQ(OutType(5), func(55.0));
- EXPECT_EQ(OutType(5), func(-55.0));
+ EXPECT_EQ(OutType(5), func(InType(55.0)));
+ EXPECT_EQ(OutType(5), func(InType(-55.0)));
}
void test_subnormal_range(Func func) {
diff --git a/libc/test/src/math/smoke/LogbTest.h b/libc/test/src/math/smoke/LogbTest.h
index 0bb6e12665b93..a9f34e7517b83 100644
--- a/libc/test/src/math/smoke/LogbTest.h
+++ b/libc/test/src/math/smoke/LogbTest.h
@@ -27,8 +27,8 @@ class LogbTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
ASSERT_FP_EQ(aNaN, func(aNaN));
ASSERT_FP_EQ(inf, func(inf));
ASSERT_FP_EQ(inf, func(neg_inf));
- ASSERT_FP_EQ(neg_inf, func(0.0));
- ASSERT_FP_EQ(neg_inf, func(-0.0));
+ ASSERT_FP_EQ(neg_inf, func(zero));
+ ASSERT_FP_EQ(neg_inf, func(neg_zero));
}
void testPowersOfTwo(LogbFunc func) {
diff --git a/libc/test/src/stdio/sprintf_test.cpp b/libc/test/src/stdio/sprintf_test.cpp
index be7c06fa918fd..45d35ad3930da 100644
--- a/libc/test/src/stdio/sprintf_test.cpp
+++ b/libc/test/src/stdio/sprintf_test.cpp
@@ -630,7 +630,7 @@ TEST(LlvmLibcSPrintfTest, PointerConv) {
ASSERT_STREQ(buff, "0x1a2b3c4d5e6f7081");
}
- written = LIBC_NAMESPACE::sprintf(buff, "%p", buff);
+ written = LIBC_NAMESPACE::sprintf(buff, "%p", &written);
EXPECT_GT(written, 0);
// Width tests:
@@ -1687,9 +1687,6 @@ TEST_F(LlvmLibcSPrintfTest, FloatDecimalConv) {
TEST_F(LlvmLibcSPrintfTest, FloatDecimalLongDoubleConv) {
ForceRoundingMode r(RoundingMode::Nearest);
- char big_buff[10000]; // Used for long doubles and other extremely wide
- // numbers.
-
// Length Modifier Tests.
// TODO(michaelrj): Add tests for LIBC_TYPES_LONG_DOUBLE_IS_FLOAT64 and 128
@@ -1741,6 +1738,8 @@ TEST_F(LlvmLibcSPrintfTest, FloatDecimalLongDoubleConv) {
"000000000000000000000000000000000000000000000000000000000000000000000000"
"00000000000000000000000000000000000000000000000000000000000000000000");
+ char big_buff[10000]; // Used for extremely wide numbers.
+
written = LIBC_NAMESPACE::sprintf(big_buff, "%Lf", 1e1000L);
ASSERT_STREQ_LEN(
written, big_buff,
>From 3ae3983d79e280ef8af261bb6dc2d96e67257ac1 Mon Sep 17 00:00:00 2001
From: OverMighty <its.overmighty at gmail.com>
Date: Sat, 13 Jul 2024 19:09:22 +0200
Subject: [PATCH 2/3] fixup! [libc] Fix warnings emitted by GCC
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Fix "warning: ISO C++ does not allow ‘alignof’ with a non-type".
---
libc/test/src/__support/CPP/type_traits_test.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libc/test/src/__support/CPP/type_traits_test.cpp b/libc/test/src/__support/CPP/type_traits_test.cpp
index 3c6268f86fbd1..fa5298a12d3fc 100644
--- a/libc/test/src/__support/CPP/type_traits_test.cpp
+++ b/libc/test/src/__support/CPP/type_traits_test.cpp
@@ -119,7 +119,7 @@ TEST(LlvmLibcTypeTraitsTest, aligned_storage) {
int a, b;
};
aligned_storage_t<sizeof(S), alignof(S)> buf;
- EXPECT_EQ(alignof(buf), alignof(S));
+ EXPECT_EQ(alignof(decltype(buf)), alignof(S));
EXPECT_EQ(sizeof(buf), sizeof(S));
}
>From 52f11f5ed15c8aaee692c52d96ff6771541baf2b Mon Sep 17 00:00:00 2001
From: OverMighty <its.overmighty at gmail.com>
Date: Mon, 15 Jul 2024 12:23:14 +0200
Subject: [PATCH 3/3] fixup! [libc] Fix warnings emitted by GCC
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Silence "warning: ignoring attributes on template argument ‘__m128i’".
---
.../test/src/string/memory_utils/op_tests.cpp | 22 +++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/libc/test/src/string/memory_utils/op_tests.cpp b/libc/test/src/string/memory_utils/op_tests.cpp
index 2c7524943c0e6..978561f31a296 100644
--- a/libc/test/src/string/memory_utils/op_tests.cpp
+++ b/libc/test/src/string/memory_utils/op_tests.cpp
@@ -192,6 +192,13 @@ TYPED_TEST(LlvmLibcOpTest, Memset, MemsetImplementations) {
}
}
+#ifdef LIBC_TARGET_ARCH_IS_X86_64
+// Prevent GCC warning due to ignored __aligned__ attributes when passing x86
+// SIMD types as template arguments.
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wignored-attributes"
+#endif // LIBC_TARGET_ARCH_IS_X86_64
+
using BcmpImplementations = testing::TypeList<
#ifdef LIBC_TARGET_ARCH_IS_X86_64
#ifdef __SSE4_1__
@@ -224,6 +231,10 @@ using BcmpImplementations = testing::TypeList<
generic::BcmpSequence<uint8_t, uint8_t, uint8_t>, //
generic::Bcmp<uint8_t>>;
+#ifdef LIBC_TARGET_ARCH_IS_X86_64
+#pragma GCC diagnostic pop
+#endif // LIBC_TARGET_ARCH_IS_X86_64
+
// Adapt CheckBcmp signature to op implementation signatures.
template <auto FnImpl>
int CmpAdaptor(cpp::span<char> p1, cpp::span<char> p2, size_t size) {
@@ -275,6 +286,13 @@ TYPED_TEST(LlvmLibcOpTest, Bcmp, BcmpImplementations) {
}
}
+#ifdef LIBC_TARGET_ARCH_IS_X86_64
+// Prevent GCC warning due to ignored __aligned__ attributes when passing x86
+// SIMD types as template arguments.
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wignored-attributes"
+#endif // LIBC_TARGET_ARCH_IS_X86_64
+
using MemcmpImplementations = testing::TypeList<
#ifdef LIBC_TARGET_ARCH_IS_X86_64
#ifdef __SSE2__
@@ -304,6 +322,10 @@ using MemcmpImplementations = testing::TypeList<
generic::MemcmpSequence<uint8_t, uint8_t, uint8_t>,
generic::Memcmp<uint8_t>>;
+#ifdef LIBC_TARGET_ARCH_IS_X86_64
+#pragma GCC diagnostic pop
+#endif // LIBC_TARGET_ARCH_IS_X86_64
+
TYPED_TEST(LlvmLibcOpTest, Memcmp, MemcmpImplementations) {
using Impl = ParamType;
constexpr size_t kSize = Impl::SIZE;
More information about the libc-commits
mailing list