[libcxx-commits] [libcxx] [libc++][format] Don't leave the output buffer full after a bulk write (PR #226791)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Mon Sep 28 01:05:07 PDT 2026


================
@@ -250,6 +250,10 @@ class __output_buffer {
       __first += __chunk;
       __n -= __chunk;
     } while (__n);
+
+    // push_back needs a free code unit, which the last chunk may have used.
----------------
philnik777 wrote:

This fix looks incorrect to me. The point of the `__prepare_write()` above is to ensure `__size_` never equals `__capacity_`. So if the condition below is true, the post-condition of `__prepare_write` is incorrect, or the code in the loop above is incorrect in writing more characters than it's supposed to.

https://github.com/llvm/llvm-project/pull/226791


More information about the libcxx-commits mailing list