This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/82777] New: incorrect result of std::filesystem::path::lexically_normal


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

            Bug ID: 82777
           Summary: incorrect result of
                    std::filesystem::path::lexically_normal
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hotwatermorning at gmail dot com
  Target Milestone: ---

With gcc HEAD 8.0.0 20171029, std::filesystem::path::lexically_normal() returns
an incorrect path.

And maybe because of this bug, std::filesystem::weakly_canonical() also returns
an incorrect path.

#include <iostream>
#include <filesystem>
namespace fs = std::filesystem;

using namespace std;

int main()
{
    fs::create_directories("./a/b");

    fs::path p("./a/b/c/../.././b/c");

    // except "a/b/c"
    // but the result will be "a/b/../b/c"
    cout << "lexically canonical :" << p.lexically_normal() << endl;
    // except "/path-to/current-dir/a/b/c"
    // but the result will be "/path-to/current-dir/a/b/b/c"
    cout << "weakly_canonical : " << fs::weakly_canonical(p) << endl;
}

An executable version is here.
https://wandbox.org/permlink/FFxvS5OwA51iyQ5B

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]