https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104454

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I did try this:

--- a/libstdc++-v3/src/c++17/fs_ops.cc
+++ b/libstdc++-v3/src/c++17/fs_ops.cc
@@ -164,6 +164,21 @@ fs::canonical(const path& p, error_code& ec)
   path result;
 #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
   const path pa = absolute(p.lexically_normal(), ec);
+#elif defined _AIX
+  // AIX realpath returns ENOENT for paths containing "//.."
+  path pa;
+  auto str = p.native();
+  auto pos = str.find("//..");
+  if (pos == str.npos)
+    pa = absolute(p, ec);
+  else
+    {
+      do {
+       str.erase(pos, 1);
+       pos = str.find("//..", pos);
+      } while (pos != str.npos);
+      pa = absolute(str, ec);
+    }
 #else
   const path pa = absolute(p, ec);
 #endif

But it doesn't solve the trailing slash problem, so isn't a complete fix
anyway. Just avoiding realpath seems simpler.

Reply via email to