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

Fix Visual Studio 2019 pedantic warning C4334: '<<': result of 32-bit… #1364

merged 1 commit into from
Oct 14, 2019

Conversation

chronoxor
Copy link
Contributor

warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)

I agree that my contributions are licensed under the {fmt} license, and agree to future changes to the licensing.

… shift implicitly converted to 64 bits (was 64-bit shift intended?)
@@ -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);

@vitaut vitaut merged commit 91f7619 into fmtlib:master Oct 14, 2019
@vitaut
Copy link
Contributor

vitaut commented Oct 14, 2019

Thinking more of it, the type doesn't really matter because assign should be inlined and mostly optimized away. So merging as is, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants