[libcxx-commits] [libcxx] [libc++][format] Discard contents since null-terminator in character arrays in formatting (PR #116571)

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Sun Feb 2 05:39:50 PST 2025


================
@@ -3189,6 +3189,12 @@ void format_tests(TestFunction check, ExceptionTest check_exception) {
     const CharT* data = buffer;
     check(SV("hello 09azAZ!"), SV("hello {}"), data);
   }
+  {
+    // https://github.com/llvm/llvm-project/issues/115935
+    // Contents after the embedded null character are discarded.
+    CharT buffer[] = {CharT('a'), CharT('b'), CharT('c'), 0, CharT('d'), CharT('e'), CharT('f'), 0};
----------------
mordante wrote:

Can you add a second test case using
`CharT buffer[] = {CharT('a'), CharT('b'), CharT('c'), 0, CharT('d'), CharT('e'), CharT('f')};`
(so without the final NUL character.)

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


More information about the libcxx-commits mailing list