Skip to content
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 Visual Studio 2019 pedantic warning C4334: '<<': result of 32-bit… #1364

Merged
merged 1 commit into from
Oct 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/fmt/format-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ FMT_FUNC void fallback_format(Double v, buffer<char>& buf, int& exp10) {
denominator <<= 1 - fp_value.e;
lower.assign(1);
if (shift != 0) {
upper_store.assign(1 << shift);
upper_store.assign(1ull << shift);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The result must be 32-bit. Does changing 1 to 1u works around the bogus warning?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately no, faliled with the similar warning:
format-inl.h(984,1): warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this fix will be suitable?
upper_store.assign((1ull << shift) & 0xFFFFFFFF);

upper = &upper_store;
}
}
Expand Down