[libc-commits] [libc] [libc] Return the written character from putc, fputc and putchar (PR #239980)

Alexey Samsonov via libc-commits libc-commits at lists.llvm.org
Sun Nov 8 18:21:28 PST 2026


================
@@ -22,7 +22,9 @@ TEST(LlvmLibcPutcTest, WriteToFile) {
 
   constexpr char simple[] = "simple letters";
   for (size_t i = 0; i < sizeof(simple); ++i) {
-    ASSERT_EQ(LIBC_NAMESPACE::putc(simple[i], file), 0);
+    // C requires the character written, taken as an unsigned char.
+    ASSERT_EQ(LIBC_NAMESPACE::putc(simple[i], file),
----------------
vonosmas wrote:

Nit - can you use EXPECT_EQ here? It's slightly more appropriate, as it'd be nice to close the file later even if putc returns incorrect result.

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


More information about the libc-commits mailing list