/W4 is required. Seems to happen in any version of {fmt}, cannot reproduce in GCC or Clang
They appear to be similar but unrelated warnings.
Here is a minimal repro:
https://compiler-explorer.com/z/Yve79WaTf
#include <fmt/format.h>
#include <fmt/chrono.h>
#include <chrono>
int main()
{
// this works
//using milliseconds = std::chrono::duration<long long, std::milli>;
// but this does not
//using milliseconds = std::chrono::duration<int, std::milli>;
// and neither does this
using milliseconds = std::chrono::duration<double, std::milli>;
fmt::print("ms {}", milliseconds{});
}
Warning stems from this line:
|
if (Factor::num != 1) { |
|
constexpr auto max1 = detail::max_value<IntermediateRep>() / |
|
static_cast<IntermediateRep>(Factor::num); |
|
if (count > max1) { |
|
ec = 1; |
|
return {}; |
|
} |
|
constexpr auto min1 = std::numeric_limits<IntermediateRep>::lowest() / |
|
static_cast<IntermediateRep>(Factor::num); |
|
if (count < min1) { |
|
ec = 1; |
|
return {}; |
|
} |
|
count *= static_cast<IntermediateRep>(Factor::num); |
|
} |
and this line:
|
if (F::digits > T::digits && |
|
from > static_cast<From>(detail::max_value<To>())) { |
|
ec = 1; |
|
return {}; |
|
} |
|
} |
/W4 is required. Seems to happen in any version of {fmt}, cannot reproduce in GCC or Clang
They appear to be similar but unrelated warnings.
Here is a minimal repro:
https://compiler-explorer.com/z/Yve79WaTf
Warning stems from this line:
fmt/include/fmt/chrono.h
Lines 246 to 260 in d141cdb
and this line:
fmt/include/fmt/chrono.h
Lines 82 to 87 in d141cdb