[libcxx-commits] [PATCH] D150044: [libc++][print] Adds FILE functions.

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Sep 12 10:29:06 PDT 2023


ldionne added inline comments.


================
Comment at: libcxx/include/print:216
+      std::__throw_system_error(EIO, "EOF while writing the formatted output");
+    std::__throw_system_error(std::ferror(__stream), "failed to write formatted output");
+  }
----------------
rprichard wrote:
> I'm wondering about this usage of std::ferror. The first argument to std::__throw_system_error appears to be a Unix errno value, whereas ferror appears to returns non-zero if the stream's error indicator flag is set.
> 
> e.g. The (print.file.pass.cpp, test_read_only) test opens a read-only file and tries to print to it. fwrite to such a stream fails with EBADF(9). glibc sets the stream's error indicator, so ferror returns 1, which is interpreted as EPERM(1). With Bionic, ferror instead returns 0, so this test is failing on Bionic/Android, because there is no OS error string suffixed to the what() result.
> 
> 
See https://reviews.llvm.org/D158930


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150044/new/

https://reviews.llvm.org/D150044



More information about the libcxx-commits mailing list