Skip to content

Commit

Permalink
Pointless comparison warnings (#2971)
Browse files Browse the repository at this point in the history
Co-authored-by: Federico Busato <fbusato@nvidia.com>
  • Loading branch information
federico-busato and fbusato committed Jul 11, 2022
1 parent 05be7a0 commit 0db43cf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions include/fmt/chrono.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ To safe_duration_cast(std::chrono::duration<FromRep, FromPeriod> from,
}
const auto min1 =
(std::numeric_limits<IntermediateRep>::min)() / Factor::num;
if (count < min1) {
if (!std::is_unsigned<IntermediateRep>::value && count < min1) {
ec = 1;
return {};
}
Expand Down Expand Up @@ -1396,7 +1396,8 @@ inline bool isfinite(T) {
// Converts value to Int and checks that it's in the range [0, upper).
template <typename T, typename Int, FMT_ENABLE_IF(std::is_integral<T>::value)>
inline Int to_nonnegative_int(T value, Int upper) {
FMT_ASSERT(value >= 0 && to_unsigned(value) <= to_unsigned(upper),
FMT_ASSERT(std::is_unsigned<Int>::value ||
(value >= 0 && to_unsigned(value) <= to_unsigned(upper)),
"invalid value");
(void)upper;
return static_cast<Int>(value);
Expand Down
2 changes: 1 addition & 1 deletion include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ template <typename T> auto convert_for_visit(T) -> monostate { return {}; }
template <typename Int>
FMT_CONSTEXPR auto to_unsigned(Int value) ->
typename std::make_unsigned<Int>::type {
FMT_ASSERT(value >= 0, "negative value");
FMT_ASSERT(std::is_unsigned<Int>::value || value >= 0, "negative value");
return static_cast<typename std::make_unsigned<Int>::type>(value);
}

Expand Down

0 comments on commit 0db43cf

Please sign in to comment.