-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Fix datatype of underlying data to avoid signed/unsigned compiler warning with MSVC #3647
Conversation
For completeness sake the exact error. Remarks: I've also tested it with the newest version of fmt (here with 10.0.0 it's the same).
|
include/fmt/format.h
Outdated
@@ -3033,7 +3033,7 @@ class bigint { | |||
bigits_.resize(to_unsigned(num_bigits + exp_difference)); | |||
for (int i = num_bigits - 1, j = i + exp_difference; i >= 0; --i, --j) | |||
bigits_[j] = bigits_[i]; | |||
std::uninitialized_fill_n(bigits_.data(), exp_difference, 0); | |||
std::uninitialized_fill_n(bigits_.data(), exp_difference, static_cast<uint32_t>(0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's replace the cast with 0u
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I've tested and adapted it.
c155e9a
to
89ee30f
Compare
thanks |
Thanks for merging. I hope a new release is planned soon. |
The following line leads to a signed/unsigned error on newer MSVC compilers (14.36.32532).
https://github.com/fmtlib/fmt/blame/f6ca4ea1990af67e00358cfe83c19f5aa4df5f19/include/fmt/format.h#L3036
Casting the value to the underlying datatype uint32_t solves the compiler issue.
std::uninitialized_fill_n(bigits_.data(), exp_difference, static_cast<uint32_t>(0));