-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
visit_any_int incorrect signed long long casting #265
Comments
Thanks for reporting this, but the existing code looks correct to me. The branches differ in that the first assigns to
although it's not technically necessary because this is UB. I've added a comment to clarify this in ae6368c. |
First, many thanks for cppformat and your super-fast answer. Thank you, really. Sorry to be a nuisance on a minor matter like this, but isn't this another instance of cppformat having better type information than C ? |
Fair enough. I've removed the conversion to an unsigned type in 7ee287d, so fmt::printf("%lld", -42); // prints -42 Thanks for reporting this and for the nice feedback. |
thank you |
Hi, I believe visit_any_int has an incorrect casting for the signed long long case.
Both branches of the if at line 329 of format.cc end up doing
arg_.long_long_value = static_cast < typename fmt::internal::MakeUnsigned < U>::Type>(value);
Perhaps the is_signed branch should do
arg_.long_long_value = static_cast < long long>(static_cast < T>(value));
instead ?
The text was updated successfully, but these errors were encountered: