PR78111 fix fallback code for filesystem::canonical
authorJonathan Wakely <jwakely@redhat.com>
Wed, 26 Oct 2016 11:29:36 +0000 (12:29 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 26 Oct 2016 11:29:36 +0000 (12:29 +0100)
PR libstdc++/78111
* src/filesystem/ops.cc (canonical): Set error for non-existent path.

From-SVN: r241549

libstdc++-v3/ChangeLog
libstdc++-v3/src/filesystem/ops.cc

index 8287f7176abffa83976c27cbc0b1f6be6b26b5ec..7d02cf4815f9601d5735353d750c75266ea5f08d 100644 (file)
@@ -1,3 +1,8 @@
+2016-10-26  Jonathan Wakely  <jwakely@redhat.com>
+
+       PR libstdc++/78111
+       * src/filesystem/ops.cc (canonical): Set error for non-existent path.
+
 2016-10-26  Uros Bizjak  <ubizjak@gmail.com>
 
        * acinclude.m4 (GLIBCXX_CHECK_FILESYSTEM_DEPS): Include <limits.h>
index 32c9c5e850de20833f96729d161fb0be9b940f81..9abcee0ea9b7829dd3565e6945e2aff13797fb36 100644 (file)
@@ -142,7 +142,11 @@ fs::canonical(const path& p, const path& base, error_code& ec)
 #endif
 
   if (!exists(pa, ec))
-    return result;
+    {
+      if (!ec)
+       ec = make_error_code(std::errc::no_such_file_or_directory);
+      return result;
+    }
   // else: we know there are (currently) no unresolvable symlink loops
 
   result = pa.root_path();