Skip to content

Commit

Permalink
fix warning in header: signed/unsigned comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
jpcima authored and vitaut committed Nov 12, 2017
1 parent 11415bc commit 1d751bc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -3940,7 +3940,8 @@ const Char *BasicFormatter<Char, ArgFormatter>::format(
default:
FMT_THROW(FormatError("width is not integer"));
}
if (value > (std::numeric_limits<int>::max)())
unsigned max_int = (std::numeric_limits<int>::max)();
if (value > max_int)
FMT_THROW(FormatError("number is too big"));
spec.width_ = static_cast<int>(value);
}
Expand Down Expand Up @@ -3978,7 +3979,8 @@ const Char *BasicFormatter<Char, ArgFormatter>::format(
default:
FMT_THROW(FormatError("precision is not integer"));
}
if (value > (std::numeric_limits<int>::max)())
unsigned max_int = (std::numeric_limits<int>::max)();
if (value > max_int)
FMT_THROW(FormatError("number is too big"));
spec.precision_ = static_cast<int>(value);
} else {
Expand Down

0 comments on commit 1d751bc

Please sign in to comment.