[libcxx-commits] [libcxx] [libc++][format] Don't leave the output buffer full after a bulk write (PR #226791)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Sep 27 08:42:45 PDT 2026
================
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// XFAIL: availability-fp_to_chars-missing
+
+// https://llvm.org/PR154670
+//
+// Formatting into a back_insert_iterator of a string, vector or deque goes
+// through a fixed-size buffer. Tests that the code unit written after an
+// argument or a fill that ends at a multiple of the buffer's size is not
+// written past the end of that buffer.
+
+#include <algorithm>
+#include <cassert>
+#include <cstddef>
+#include <deque>
+#include <format>
+#include <iterator>
+#include <string>
+#include <vector>
+
+#include "make_string.h"
+#include "test_macros.h"
+
+#define SV(S) MAKE_STRING_VIEW(CharT, S)
+
+template <class CharT, class Container>
+void test(std::size_t size) {
+ const std::basic_string<CharT> arg(size, CharT('a'));
+ const std::basic_string<CharT> expected = arg + CharT('!');
+
+ { // The argument is copied.
----------------
frederick-vs-ja wrote:
No change requested for these cases. Maybe it's better to add these cases to `format_tests.h` and let `format_to.pass.cpp` and `format_to_n.pass.cpp` cover them, but that seemingly requires significantly more works.
https://github.com/llvm/llvm-project/pull/226791
More information about the libcxx-commits
mailing list