diff --git a/format.cc b/format.cc index ee3224bc..88801fc0 100644 --- a/format.cc +++ b/format.cc @@ -34,6 +34,7 @@ #include #include #include +#include // for std::ptrdiff_t #if defined(_WIN32) && defined(__MINGW32__) # include @@ -1040,10 +1041,10 @@ void fmt::internal::PrintfFormatter::format( ArgConverter(arg, *s).visit(arg); break; case 'z': - ArgConverter(arg, *s).visit(arg); + ArgConverter(arg, *s).visit(arg); break; case 't': - ArgConverter(arg, *s).visit(arg); + ArgConverter(arg, *s).visit(arg); break; case 'L': // printf produces garbage when 'L' is omitted for long double, no diff --git a/format.h b/format.h index 36bc0109..35dac05b 100644 --- a/format.h +++ b/format.h @@ -32,7 +32,6 @@ #include #include -#include // for std::ptrdiff_t #include #include #include @@ -484,11 +483,12 @@ class Buffer { template template void Buffer::append(const U *begin, const U *end) { - std::ptrdiff_t num_elements = end - begin; - if (size_ + num_elements > capacity_) - grow(size_ + num_elements); + assert(begin <= end); + std::size_t new_size = size_ + (end - begin); + if (new_size > capacity_) + grow(new_size); std::copy(begin, end, internal::make_ptr(ptr_, capacity_) + size_); - size_ += num_elements; + size_ = new_size; } namespace internal {