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 sign conversion warnings #790

Merged
merged 1 commit into from
Jun 27, 2018
Merged

Fix sign conversion warnings #790

merged 1 commit into from
Jun 27, 2018

Conversation

foonathan
Copy link
Contributor

Just a couple static casts to fix -Wsign-conversion warnings.

There are a couple of weird things though, please take a look.
For example, why is precision an int and not an unsigned?

@@ -749,7 +749,7 @@ class basic_parse_context : private ErrorHandler {

// Advances the begin iterator to ``it``.
FMT_CONSTEXPR void advance_to(iterator it) {
format_str_.remove_prefix(it - begin());
format_str_.remove_prefix(static_cast<std::size_t>(it - begin()));
Copy link
Contributor

Choose a reason for hiding this comment

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

Here and below I suggest using to_unsigned instead of a cast because it has an extra check (assert) that the value is actually nonzero.

@vitaut
Copy link
Contributor

vitaut commented Jun 24, 2018

Thanks for the PR, just one small comment inline.

why is precision an int and not an unsigned?

-1 is used to denote "no precision" since 0 is a valid precision.

@foonathan foonathan force-pushed the warning-fix branch 2 times, most recently from 244acd0 to e6b91ea Compare June 24, 2018 17:09
@foonathan foonathan merged commit c6d9730 into master Jun 27, 2018
@foonathan foonathan deleted the warning-fix branch June 27, 2018 12:31
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