-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
warning C4307: “*” on VS2017 #3163
Comments
I wasn't able to reproduce this in https://godbolt.org/z/baaGbjebz. Please provide more repro details. |
Closing for now but feel free to reopen with a repro (ideally on godbolt). |
There is indeed this problem, and I have reproduced it on the website you provided, but you need to choose x64msvc19.22 and earlier versions of the compiler.I copied the warning message: x64 msvc v19.22 /std:c++latest /W2 |
And here is the logic behind the code. Granlund-Montgomery, Section 9, explains that to check if an unsigned integer This is because multiplying Granlund-Montgomery also explains that, to check
In our case, |
Thanks, @jk-jeon, for the detailed explanation. Considering that unsigned overflow is well-defined and the warning appears to be a false positive fixed in more recent versions of MSVC, I don't think we need to do anything. It can still be suppressed using |
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 fmtlib#3163 (comment) and write the explicit value of mod_inv_25.
build in spdlog 1.11.0 header only,
spdlog\fmt\bundled\format-inl.h(1154): warning C4307: “*”
// Remove trailing zeros from n and return the number of zeros removed (float)
FMT_INLINE int remove_trailing_zeros(uint32_t& n) noexcept {
FMT_ASSERT(n != 0, "");
const uint32_t mod_inv_5 = 0xcccccccd;
const uint32_t mod_inv_25 = mod_inv_5 * mod_inv_5; //// ?????
The text was updated successfully, but these errors were encountered: