[libcxx-commits] [PATCH] D150044: [libc++][print] Adds FILE functions.
Ryan Prichard via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Aug 17 16:27:56 PDT 2023
rprichard 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");
+ }
----------------
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.
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