[Bug libstdc++/87846] New: std::filesystem::create_directories with a path with a trailing slash does not create any directory
arnaud02 at users dot sourceforge.net
gcc-bugzilla@gcc.gnu.org
Thu Nov 1 12:01:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87846
Bug ID: 87846
Summary: std::filesystem::create_directories with a path with a
trailing slash does not create any directory
Product: gcc
Version: 8.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: arnaud02 at users dot sourceforge.net
Target Milestone: ---
Calling std::filesystem::create_directories with a path with a trailing
separator (e.g. "./a/b/") does not create any directory.
VS 2017 15.8 creates the desired directories.
Is GCC incorrect?
>cat fs.cpp
//
https://developercommunity.visualstudio.com/content/problem/278829/stdfilesystemcreate-directories-returns-false-if-p.html
#include <filesystem>
#include <iostream>
namespace fs = std::filesystem;
int main()
{
fs::path d{"./a/b/"};
// bug: d is not created due to trailing slash when built with GCC 8. Works
with VS2017.8.
fs::create_directories(d);
std::cout << std::boolalpha
<< fs::exists(d) << ' '
<< fs::is_directory(d) << '\n';
for (auto const& e : fs::recursive_directory_iterator("."))
std::cout << "In current_path: " << e.path() << '\n';
}
>g++ -std=c++17 fs.cpp -lstdc++fs
>./a.out
false false
In current_path: "./a.out"
In current_path: "./fs.cpp"
>gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/buildarea/opt/gcc/gcc-820-rh6/libexec/gcc/x86_64-pc-linux-gnu/8.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /tmp/gcc8/gcc-build/srcdir/gcc-8.2.0/configure
--prefix=/buildarea/opt/gcc/gcc-820-rh6 --enable-languages=c,c++,fortran
--disable-multilib
Thread model: posix
More information about the Gcc-bugs
mailing list