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 a conversion warning with Clang10 on Windows #1750

Merged
merged 1 commit into from
Jul 3, 2020

Conversation

0x8000-0000
Copy link
Contributor

Fixes #1747

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

@@ -566,7 +566,7 @@ template <typename U>
void buffer<T>::append(const U* begin, const U* end) {
size_t new_size = size_ + to_unsigned(end - begin);
reserve(new_size);
std::uninitialized_copy(begin, end, make_checked(ptr_, capacity_) + size_);
std::uninitialized_copy(begin, end, make_checked(ptr_ + size_, capacity_));
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the PR. I think you also need to subtract size_ from capacity_.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do, but why do all the test pass? :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Because we don't write over capacity. The whole checked iterator machinery in MSVC is completely useless and is here mostly to avoid warnings but let's provide correct bounds anyway.

@vitaut vitaut merged commit 31ce6bc into fmtlib:master Jul 3, 2020
@vitaut
Copy link
Contributor

vitaut commented Jul 3, 2020

Thank you!

@0x8000-0000 0x8000-0000 deleted the fix-conversion-warning branch July 7, 2020 03:57
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.

-Wsign-conversion warning with Clang10 on Windows
2 participants