diff --git a/libcxx/include/__format/formatter_integral.h b/libcxx/include/__format/formatter_integral.h --- a/libcxx/include/__format/formatter_integral.h +++ b/libcxx/include/__format/formatter_integral.h @@ -404,8 +404,12 @@ __out_it = _VSTD::copy(__begin, __first, _VSTD::move(__out_it)); this->__alignment = _Flags::_Alignment::__right; this->__fill = _CharT('0'); - unsigned __size = __first - __begin; - this->__width -= _VSTD::min(__size, this->__width); + auto __size = __first - __begin; + if (this->__width <= __size) { + this->__width = 0; + } else { + this->__width -= __size; + } } return __write(__first, __last, _VSTD::move(__out_it));