[libcxx-commits] [libcxx] [libc++] Make std::filesystem::canonical throw when given empty path (PR #77223)

via libcxx-commits libcxx-commits at lists.llvm.org
Sun Jan 7 07:33:45 PST 2024


================
@@ -82,6 +82,8 @@ path __canonical(path const& orig_p, error_code* ec) {
   path cwd;
   ErrorHandler<path> err("canonical", ec, &orig_p, &cwd);
 
+  if (orig_p.empty())
+    return err.report(capture_errno());
----------------
Yuki-cpp wrote:

Just a heads up.

By moving that test (a slightly modified version) to `__do_absolute` as you suggest, I can get `absolute`, `canonical` and `weakly_canonical` to work as expected. However it appears that both `proximate` and `relative` are dependent on `weakly_canonical` and are both in their tests depending on the `""` becomes `current_dir` behavior.

Modifying your example, I can highlight some more discrepancies : https://godbolt.org/z/14h8Pv7vc

I believe I can iron those out, but it will take me a bit more time and extend the scope of this PR. Is that acceptable?

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


More information about the libcxx-commits mailing list