[libcxx-commits] [libcxx] [libc++][filesystem] Report an error for canonical("") (PR #215031)

Hristo Hristov via libcxx-commits libcxx-commits at lists.llvm.org
Sun Aug 9 03:31:42 PDT 2026


================
@@ -1042,8 +1051,12 @@ path __temp_directory_path(error_code* ec) {
 path __weakly_canonical(const path& p, error_code* ec) {
   ErrorHandler<path> err("weakly_canonical", ec, &p);
 
+  // weakly_canonical() never requires its argument to exist ([fs.op.weakly.canonical]),
+  // so an empty path -- which has no leading elements at all -- resolves to
+  // the current directory directly. This must not go through __canonical(""),
+  // which is now required to report an error for an empty path.
----------------
Zingam wrote:

This feels like too much explanation for something that comes from The Standard.

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


More information about the libcxx-commits mailing list