From 88ba091e3347a634dd23f8ba646d4b83c9fbcd6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 8 Nov 2024 12:16:41 +0100 Subject: [PATCH] Fix and unset "-Wno-nan-infinity-disabled" --- .github/workflows/build-checks.yml | 3 --- src/test/durationutiltest.cpp | 10 +++++----- src/test/frametest.cpp | 13 +++++-------- src/test/mathutiltest.cpp | 6 +++--- src/util/fpclassify.cpp | 9 +++++++++ src/util/fpclassify.h | 3 +++ 6 files changed, 25 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build-checks.yml b/.github/workflows/build-checks.yml index 4ea6b5a182a..0ce96bab71c 100644 --- a/.github/workflows/build-checks.yml +++ b/.github/workflows/build-checks.yml @@ -68,8 +68,6 @@ jobs: CXX: clazy - name: Configure (clang-tidy) if: matrix.name == 'clang-tidy' - # Our code contains the use of infinity(), which Clang >= 18 reports - # as error, if you compile with -fast-math run: | cmake \ -DCMAKE_BUILD_TYPE=Debug \ @@ -90,7 +88,6 @@ jobs: -DMAD=ON \ -DMODPLUG=ON \ -DWAVPACK=ON \ - -DCMAKE_CXX_FLAGS="-Wno-nan-infinity-disabled" \ .. working-directory: build env: diff --git a/src/test/durationutiltest.cpp b/src/test/durationutiltest.cpp index f918d1a3f5c..b3cbc1429d5 100644 --- a/src/test/durationutiltest.cpp +++ b/src/test/durationutiltest.cpp @@ -1,10 +1,10 @@ -#include - #include -#include "util/duration.h" - #include +#include + +#include "util/duration.h" +#include "util/fpclassify.h" namespace { @@ -115,7 +115,7 @@ TEST_F(DurationUtilTest, formatTime) { formatTime("24:00:00.000", 24 * 3600); formatTime("24:00:01.000", 24 * 3600 + 1); formatTime("25:00:01.000", 25 * 3600 + 1); - formatTime("?", std::numeric_limits::infinity()); + formatTime("?", util_double_infinity()); formatTime("?", -1); } diff --git a/src/test/frametest.cpp b/src/test/frametest.cpp index 6df0eb8332a..ae930d9c5ed 100644 --- a/src/test/frametest.cpp +++ b/src/test/frametest.cpp @@ -3,6 +3,7 @@ #include #include "audio/frame.h" +#include "util/fpclassify.h" class FrameTest : public testing::Test { }; @@ -18,7 +19,7 @@ TEST_F(FrameTest, TestFramePosValid) { // Denormals EXPECT_TRUE(mixxx::audio::FramePos(0.0).isValid()); EXPECT_TRUE(mixxx::audio::FramePos(std::numeric_limits::min() / 2.0).isValid()); - EXPECT_FALSE(mixxx::audio::FramePos(std::numeric_limits::infinity()).isValid()); + EXPECT_FALSE(mixxx::audio::FramePos(util_double_infinity()).isValid()); // NaN EXPECT_FALSE(mixxx::audio::FramePos().isValid()); EXPECT_FALSE(mixxx::audio::FramePos(std::numeric_limits::quiet_NaN()).isValid()); @@ -54,16 +55,12 @@ TEST_F(FrameTest, TestFramePosEquality) { mixxx::audio::FramePos(std::numeric_limits< mixxx::audio::FramePos::value_t>::quiet_NaN())); EXPECT_EQ(mixxx::audio::FramePos(), - mixxx::audio::FramePos(std::numeric_limits< - mixxx::audio::FramePos::value_t>::infinity())); + mixxx::audio::FramePos(util_double_infinity())); EXPECT_EQ(mixxx::audio::FramePos(), - mixxx::audio::FramePos( - -std::numeric_limits< - mixxx::audio::FramePos::value_t>::infinity())); + mixxx::audio::FramePos(-util_double_infinity())); EXPECT_EQ(mixxx::audio::FramePos(std::numeric_limits< mixxx::audio::FramePos::value_t>::quiet_NaN()), - mixxx::audio::FramePos(std::numeric_limits< - mixxx::audio::FramePos::value_t>::infinity())); + mixxx::audio::FramePos(util_double_infinity())); } TEST_F(FrameTest, LowerFrameBoundary) { diff --git a/src/test/mathutiltest.cpp b/src/test/mathutiltest.cpp index eb3db2e383d..aba072f7241 100644 --- a/src/test/mathutiltest.cpp +++ b/src/test/mathutiltest.cpp @@ -1,9 +1,9 @@ #include #include -#include #include "util/denormalsarezero.h" +#include "util/fpclassify.h" #include "util/math.h" namespace { @@ -51,11 +51,11 @@ TEST_F(MathUtilTest, IsNaN) { TEST_F(MathUtilTest, IsInf) { // Test floats can be recognized as infinity. EXPECT_FALSE(util_isinf(0.0f)); - EXPECT_TRUE(util_isinf(std::numeric_limits::infinity())); + EXPECT_TRUE(util_isinf(util_float_infinity())); // Test doubles can be recognized as infinity. EXPECT_FALSE(util_isinf(0.0f)); - EXPECT_TRUE(util_isinf(std::numeric_limits::infinity())); + EXPECT_TRUE(util_isinf(util_double_infinity())); } TEST_F(MathUtilTest, Denormal) { diff --git a/src/util/fpclassify.cpp b/src/util/fpclassify.cpp index 4b2d12d66e7..2fd42641c5d 100644 --- a/src/util/fpclassify.cpp +++ b/src/util/fpclassify.cpp @@ -8,6 +8,7 @@ #endif #include +#include int util_fpclassify(float x) { return std::fpclassify(x); @@ -48,3 +49,11 @@ int util_isnan(double x) { int util_isinf(double x) { return std::isinf(x); } + +float util_float_infinity() { + return std::numeric_limits::infinity(); +} + +double util_double_infinity() { + return std::numeric_limits::infinity(); +} diff --git a/src/util/fpclassify.h b/src/util/fpclassify.h index f639be4873a..4966254b019 100644 --- a/src/util/fpclassify.h +++ b/src/util/fpclassify.h @@ -24,3 +24,6 @@ int util_isnan(double x); int util_isinf(float x); int util_isinf(double x); + +float util_float_infinity(); +double util_double_infinity();