Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22476

Return value of std::filesystem::create_directories() on paths with trailing slash

$
0
0

GCC (10.0.1) and Clang (11.0.0)/MSVC (VS 16.4.3) show different behavior concerning std::filesystem::create_directories() when a non-existing path with a trailing slash is given as argument.

More precisely, while all three compilers indeed create the directory, the latter two return false in that case, making the return value of std::filesystem::create_directories() ambigous (and counter-intuitive).

Specifically, if no file exists at path "a/b/c", then the following program,

#include <filesystem>
#include <iostream>

int main() {
    std::cout << std::boolalpha << std::filesystem::create_directories("a/b/c/");
}

creates a directory at that path, but prints false under Clang/MSVC while true under GCC.

Which is the correct behavior?


Viewing all articles
Browse latest Browse all 22476

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>