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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |powerpc-ibm-aix7.2.0.0
                 CC|                            |dje at gcc dot gnu.org

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This may not be worth fixing, because AIX realpath is broken anyway

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/stat.h>

int main()
{
  rmdir("testdir/foo");
  rmdir("testdir");
  mkdir("testdir", S_IRWXU);
  mkdir("testdir/foo", S_IRWXU);
  puts(realpath("testdir/foo//..", 0));
}


This prints $PWD/testdir/foo but should be $PWD/testdir or $PWD/testdir/

This means that even with this libstdc++ patch, the tests still fail:

--- a/libstdc++-v3/src/c++17/fs_ops.cc
+++ b/libstdc++-v3/src/c++17/fs_ops.cc
@@ -182,6 +182,10 @@ fs::canonical(const path& p, error_code& ec)
       if (buf == nullptr)
        buf.reset(rp);
       result.assign(rp);
+      // AIX realpath("/foo/.", 0) returns "/foo/" (and POSIX allows that).
+      // For consistency across platforms we remove the trailing slash.
+      if (!result.has_filename() && result.has_relative_path())
+       result = result.parent_path();
       ec.clear();
       return result;
     }

Reply via email to