[libcxx-commits] [libcxx] Reapply "[libc++] Optimize fstream::read" (PR #206453)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jul 1 07:23:31 PDT 2026
================
@@ -68,6 +68,25 @@ int main(int, char**) {
test_buffer.resize(24);
assert(std::string(test_buffer.data(), 24) == "to test buffer behaviour");
}
+ { // Ensure that read fails gracefully with an unopened ifstream
+ // See https://llvm.org/PR168628
+ char buf[10];
+ std::ifstream ifs;
+
+ assert(!ifs.is_open());
+ assert(!ifs.bad());
+ assert(!ifs.fail());
+ assert(!ifs.eof());
+ assert(ifs.good());
+
+ ifs.read(buf, sizeof(buf));
----------------
ldionne wrote:
It feels like this should be tested in the test file for `ifstream::read` instead.
https://github.com/llvm/llvm-project/pull/206453
More information about the libcxx-commits
mailing list