Add more suppressions on float comparisons

This commit is contained in:
Sven Fink 2021-08-04 08:34:53 +02:00 committed by Chaoya Li
parent 8c6ea747c3
commit 5b6fd51128
3 changed files with 12 additions and 0 deletions

View File

@ -1066,6 +1066,8 @@ char* to_chars(char* first, const char* last, FloatType value)
*first++ = '-'; *first++ = '-';
} }
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"
if (value == 0) // +-0 if (value == 0) // +-0
{ {
*first++ = '0'; *first++ = '0';
@ -1074,6 +1076,7 @@ char* to_chars(char* first, const char* last, FloatType value)
*first++ = '0'; *first++ = '0';
return first; return first;
} }
#pragma GCC diagnostic pop
JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10); JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10);

View File

@ -6278,6 +6278,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
*/ */
friend bool operator==(const_reference lhs, const_reference rhs) noexcept friend bool operator==(const_reference lhs, const_reference rhs) noexcept
{ {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"
const auto lhs_type = lhs.type(); const auto lhs_type = lhs.type();
const auto rhs_type = rhs.type(); const auto rhs_type = rhs.type();
@ -6342,6 +6344,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
} }
return false; return false;
#pragma GCC diagnostic pop
} }
/*! /*!

View File

@ -15993,6 +15993,8 @@ char* to_chars(char* first, const char* last, FloatType value)
*first++ = '-'; *first++ = '-';
} }
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"
if (value == 0) // +-0 if (value == 0) // +-0
{ {
*first++ = '0'; *first++ = '0';
@ -16001,6 +16003,7 @@ char* to_chars(char* first, const char* last, FloatType value)
*first++ = '0'; *first++ = '0';
return first; return first;
} }
#pragma GCC diagnostic pop
JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10); JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10);
@ -23375,6 +23378,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
*/ */
friend bool operator==(const_reference lhs, const_reference rhs) noexcept friend bool operator==(const_reference lhs, const_reference rhs) noexcept
{ {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"
const auto lhs_type = lhs.type(); const auto lhs_type = lhs.type();
const auto rhs_type = rhs.type(); const auto rhs_type = rhs.type();
@ -23439,6 +23444,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
} }
return false; return false;
#pragma GCC diagnostic pop
} }
/*! /*!