public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/104454] New: filesystem::canonical needs to strip trailing slash
@ 2022-02-08 21:46 redi at gcc dot gnu.org
2022-02-09 14:54 ` [Bug libstdc++/104454] " redi at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2022-02-08 21:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104454
Bug ID: 104454
Summary: filesystem::canonical needs to strip trailing slash
Product: gcc
Version: 11.2.1
Status: UNCONFIRMED
Keywords: testsuite-fail
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
27_io/filesystem/operations/canonical.cc FAILs on AIX because the result of
realpath("foo/.", 0) is "foo/" whereas on Linux it's "foo".
For consistency across platforms, filesystem::canonical should remove that
trailing slash.
27_io/filesystem/operations/weakly_canonical.cc also FAILs on AIX, probably for
the same reason.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug libstdc++/104454] filesystem::canonical needs to strip trailing slash
2022-02-08 21:46 [Bug libstdc++/104454] New: filesystem::canonical needs to strip trailing slash redi at gcc dot gnu.org
@ 2022-02-09 14:54 ` redi at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2022-02-09 14:54 UTC (permalink / raw)
To: gcc-bugs
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;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-02-09 14:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-08 21:46 [Bug libstdc++/104454] New: filesystem::canonical needs to strip trailing slash redi at gcc dot gnu.org
2022-02-09 14:54 ` [Bug libstdc++/104454] " redi at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).