https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87116
Bug ID: 87116 Summary: Incorrect result of std::filesystem::path::lexically_normal() for more than 3 dot-dot elements Product: gcc Version: 8.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: benjamin.kollenda at rub dot de Target Milestone: --- Created attachment 44611 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44611&action=edit Example code with test inputs and expected outputs Using std::filesystem::path::lexically_normal() with gcc 8.2.0 produces incorrect results for paths with three or more dot-dot elements. Example input: comp0/comp1/comp2/comp3/../../../comp4/comp5/comp6/comp7 Expected output: comp0/comp4/comp5/comp6/comp7 Actual output: comp4/comp5/comp6/comp7 Using just 2 dot-dot elements works as expected: Input: comp0/comp1/comp2/comp3/../../comp4/comp5/comp6/comp7 Output: comp0/comp1/comp4/comp5/comp6/comp7 This seems to be related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82777 but not fixed already. The testcase given in that bugreport works correctly on my system. GCC version is 8.2.0 on Arch Linux 64bit. Commandline: g++ -std=c++17 filesystem.cpp -lstdc++fs -Wall -Wextra -o filesystem I attached a file containing test inputs and expected outputs.