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

            Bug ID: 124942
           Summary: filesystem::path("//").lexically_normal() results in
                    path("//") and not path("/")
           Product: gcc
           Version: 15.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: services+gccbugs at vasama dot org
  Target Milestone: ---

Except when targeting Cygwin, `filesystem::path("//")` is considered to have a
root directory and no root name. In this case the standard is clear that any
directory-separators should be normalised. libstdc++ fails to normalise this
and instead returns the path unchanged.

Reproducer: https://godbolt.org/z/MhPr8sYb4

#include <filesystem>
#include <iostream>

int main()
{
    auto p = std::filesystem::path("//");
    std::cout << "has root name:      " << p.has_root_name() << "\n";       //
Prints 0
    std::cout << "has root directory: " << p.has_root_directory() << "\n";  //
Prints 1
    std::cout << "has relative path:  " << p.has_relative_path() << "\n";   //
Prints 0
    std::cout << "lexically normal:   " << p.lexically_normal() << "\n";    //
Prints "//"
}
```
  • [Bug libstdc++/124942] New... services+gccbugs at vasama dot org via Gcc-bugs

Reply via email to