mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-26 09:28:21 +00:00
Add a comment to clarify why convert to unsigned
This commit is contained in:
parent
bb7a80b1ab
commit
ae6368c985
@ -328,6 +328,9 @@ class ArgConverter : public fmt::internal::ArgVisitor<ArgConverter<T>, void> {
|
|||||||
} else {
|
} else {
|
||||||
if (is_signed) {
|
if (is_signed) {
|
||||||
arg_.type = Arg::LONG_LONG;
|
arg_.type = Arg::LONG_LONG;
|
||||||
|
// Convert value to unsigned type before converting to long long for
|
||||||
|
// consistency with glibc's printf even though in general it's UB:
|
||||||
|
// std::printf("%lld", -42); // prints "4294967254"
|
||||||
arg_.long_long_value =
|
arg_.long_long_value =
|
||||||
static_cast<typename fmt::internal::MakeUnsigned<U>::Type>(value);
|
static_cast<typename fmt::internal::MakeUnsigned<U>::Type>(value);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user