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

VS2022 17.2: C4189: 'zero': local variable is initialized but not referenced #2891 #2892

Merged
merged 2 commits into from
May 13, 2022
Merged

Conversation

chronoxor
Copy link
Contributor

No description provided.

@vitaut
Copy link
Contributor

vitaut commented May 12, 2022

The warning looks wrong because zero is referenced here:

if (num_zeros > 0) it = detail::fill_n(it, num_zeros, zero);
. Could you report to Microsoft?

@chronoxor
Copy link
Contributor Author

chronoxor commented May 13, 2022

Reported to Microsoft with a sample to reproduce - https://godbolt.org/z/cT6sKs3dY

https://developercommunity.visualstudio.com/t/CL-version-193231328-generates-false-w/10040986

@@ -2203,7 +2203,7 @@ FMT_CONSTEXPR20 auto do_write_float(OutputIt out, const DecimalFP& fp,
-> OutputIt {
auto significand = fp.significand;
int significand_size = get_significand_size(fp);
constexpr Char zero = static_cast<Char>('0');
Char zero = static_cast<Char>('0');
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's make it const so that it doesn't add to lambda capture.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just checked - compiles without warnings!

@chronoxor
Copy link
Contributor Author

Updated PR with const Char zero = static_cast<Char>('0');

@vitaut vitaut merged commit 3e28dc0 into fmtlib:master May 13, 2022
@vitaut
Copy link
Contributor

vitaut commented May 13, 2022

Thank you

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.

None yet

2 participants