Bug 106127 - experimental::filesystem::path("//") should be a root-directory not a root-name (experimental/filesystem/operations/absolute.cc)
Summary: experimental::filesystem::path("//") should be a root-directory not a root-na...
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: testsuite-fail
: 113589 (view as bug list)
Depends on:
Blocks:
 
Reported: 2022-06-28 20:40 UTC by Jonathan Wakely
Modified: 2024-01-25 04:34 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2024-01-24 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Wakely 2022-06-28 20:40:42 UTC
Our Filesystem TS implementation treats // the same as //x which is probably wrong.

It causes experimental/filesystem/operations/absolute.cc to FAIL on Windows, because absolute(path("//"), "z:\\tmp") returns "//\\tmp" which is a root-name. (On the other hand, the specification for experimental::filesystem::absolute is known to be broken for Windows, and was completely changed for C++17).
Comment 1 Jonathan Wakely 2022-06-28 20:47:29 UTC
This patch:

--- a/libstdc++-v3/src/filesystem/path.cc
+++ b/libstdc++-v3/src/filesystem/path.cc
@@ -377,7 +377,7 @@ path::_M_split_cmpts()
          if (len == 2)
            {
              // entire path is just "//"
-             _M_type = _Type::_Root_name;
+             _M_type = _Type::_Root_dir;
              return;
            }
 
fixes the absolute.cc test on Windows and causes only one new FAIL (on all targets):

/home/jwakely/src/gcc/gcc/libstdc++-v3/testsuite/experimental/filesystem/path/decompose/root_directory.cc:52: void test02(): Assertion 'rootdir.string()[0] != '/'' failed.
FAIL: experimental/filesystem/path/decompose/root_directory.cc execution test

The test seems questionable anyway:

void
test02()
{
  for (const path p : __gnu_test::test_paths)
  {
    path rootdir = p.root_directory();
    // If root-directory is composed of 'slash name',
    // 'slash' is excluded from the returned string.
    if (!rootdir.empty() && rootdir.string() != "/")
      VERIFY( rootdir.string()[0] != '/' );
  }
}

This fails with the change because "//" behaves the same as "/" and so still has a leading slash.
Comment 2 Andrew Pinski 2024-01-24 23:56:40 UTC
*** Bug 113589 has been marked as a duplicate of this bug. ***