[libcxx-commits] [libcxx] [libc++] Fix insufficiently guarded call to `copy_file_impl_fstream` (PR #214706)

via libcxx-commits libcxx-commits at lists.llvm.org
Fri Aug 7 04:31:18 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: Anthony Latsis (AnthonyLatsis)

<details>
<summary>Changes</summary>

copy_file_impl_fstream is only defined under
`_LIBCPP_FILESYSTEM_NEED_FSTREAM`, which additionally requires `_LIBCPP_HAS_LOCALIZATION`. The `_LIBCPP_FILESYSTEM_USE_FSTREAM` dispatch called it unconditionally, so a build with filesystem enabled and localization disabled failed on any platform that provides neither sendfile nor copyfile:

```
error: use of undeclared identifier 'copy_file_impl_fstream'
```

Report `EINVAL` instead, as the `sendfile`/`copy_file_range` dispatch above already does in the same situation.

Assisted-by: Claude Code

---
Full diff: https://github.com/llvm/llvm-project/pull/214706.diff


1 Files Affected:

- (modified) libcxx/src/filesystem/operations.cpp (+6) 


``````````diff
diff --git a/libcxx/src/filesystem/operations.cpp b/libcxx/src/filesystem/operations.cpp
index 3ff62c102d0ad..7099cd2c75ab6 100644
--- a/libcxx/src/filesystem/operations.cpp
+++ b/libcxx/src/filesystem/operations.cpp
@@ -362,7 +362,13 @@ bool copy_file_impl(FileDescriptor& read_fd, FileDescriptor& write_fd, error_cod
 }
 #elif defined(_LIBCPP_FILESYSTEM_USE_FSTREAM)
 bool copy_file_impl(FileDescriptor& read_fd, FileDescriptor& write_fd, error_code& ec) {
+#  if defined(_LIBCPP_FILESYSTEM_NEED_FSTREAM)
   return copy_file_impl_fstream(read_fd, write_fd, ec);
+#  else
+  // iostreams are unavailable in the no-locale build, just fail.
+  ec.assign(EINVAL, std::system_category());
+  return false;
+#  endif
 }
 #else
 #  error "Unknown implementation for copy_file_impl"

``````````

</details>


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


More information about the libcxx-commits mailing list