diff --git a/format.cc b/format.cc index fbf932fc..2aa38bc0 100644 --- a/format.cc +++ b/format.cc @@ -328,6 +328,9 @@ class ArgConverter : public fmt::internal::ArgVisitor, void> { } else { if (is_signed) { 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 = static_cast::Type>(value); } else {