Skip to content

Commit

Permalink
revert non-working workaround for #3163
Browse files Browse the repository at this point in the history
This fix for warning C4307: '*': integral constant overflow leads to warning C4309: 'static_cast': truncation of constant value, which is not better (both are leve 3 VS warnings).
Revert to the original code that is clearer and also present further in this source code.
Alternatively, to avoid any warning, one could follow the third suggestion of #3163 (comment) and write the explicit value of mod_inv_25.
  • Loading branch information
florimond-collette authored May 17, 2023
1 parent 0bf6ed7 commit 9752ab5
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions include/fmt/format-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1131,11 +1131,8 @@ bool is_left_endpoint_integer_shorter_interval(int exponent) noexcept {
FMT_INLINE int remove_trailing_zeros(uint32_t& n) noexcept {
FMT_ASSERT(n != 0, "");
// Modular inverse of 5 (mod 2^32): (mod_inv_5 * 5) mod 2^32 = 1.
// See https://github.com/fmtlib/fmt/issues/3163 for more details.
const uint32_t mod_inv_5 = 0xcccccccd;
// Casts are needed to workaround a bug in MSVC 19.22 and older.
const uint32_t mod_inv_25 =
static_cast<uint32_t>(uint64_t(mod_inv_5) * mod_inv_5);
const uint32_t mod_inv_25 = mod_inv_5 * mod_inv_5;

int s = 0;
while (true) {
Expand Down

0 comments on commit 9752ab5

Please sign in to comment.