diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index 05e9de87..85680b3b 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -1403,10 +1403,8 @@ inline Int to_nonnegative_int(T value, Int upper) { } template ::value)> inline Int to_nonnegative_int(T value, Int upper) { - FMT_ASSERT( - std::isnan(value) || (value >= 0 && value <= static_cast(upper)), - "invalid value"); - (void)upper; + if (value < 0 || value > static_cast(upper)) + throw format_error("invalid value"); return static_cast(value); }