-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Explicitly cast int -> char to prevent conversion warnings #553
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. One of the casts makes total sense but the one in visit_int
seems misplaced and makes tests to fail. Do you get warnings there too?
fmt/format.h
Outdated
@@ -1671,7 +1671,7 @@ class ArgVisitor { | |||
FMT_ASSERT(false, "invalid argument type"); | |||
break; | |||
case Arg::INT: | |||
return FMT_DISPATCH(visit_int(arg.int_value)); | |||
return FMT_DISPATCH(visit_int(static_cast<char>(arg.int_value))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is correct.
Hi, You were right, that change was wrong. I've changed the commit ton only include an explicit cast in
is related to the
I see only one non-void candidate that could fit in |
The reason why the test is failing is that the character type can be void visit_char(char value) to void visit_char(int value) in line 113 of |
Great, that fixes the warnings, all tests passing. Thanks a lot for your time. |
Merged, thanks! |
This prevents integer conversion warnings so the library can be compiled with GCC and
-Wconversion
enabled (also-Werror -Wall -Wextra -pedantic
, but I think the offender was-Wconversion
) as "discussed" in #552.Note this change makes possible to build fmt with these flags, but the unit tests cannot be compiled, googletest triggers a lot of conversion warnings.