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

--- Comment #2 from Moritz Bunkus <moritz at bunkus dot org> ---
The following code tests forward & backward slashes with both std::filesystem
(gcc 10.2.0, mingw via MXE) and boost::filesystem (Boost 1.74.0):

  auto slashes     = R"(//server/share/file.txt)"s;
  auto backslashes = R"(\\server\share\file.txt)"s;

  std::cout << "std::filesystem::path("   << slashes     << ").has_root_name()
" << std::filesystem::path{slashes}.has_root_name()       << "\n"
            << "std::filesystem::path("   << backslashes << ").has_root_name()
" << std::filesystem::path{backslashes}.has_root_name()   << "\n"
            << "boost::filesystem::path(" << slashes     << ").has_root_name()
" << boost::filesystem::path{slashes}.has_root_name()     << "\n"
            << "boost::filesystem::path(" << backslashes << ").has_root_name()
" << boost::filesystem::path{backslashes}.has_root_name() << "\n";

The output of that snippet is:

std::filesystem::path(//server/share/file.txt).has_root_name() 0
std::filesystem::path(\\server\share\file.txt).has_root_name() 0
boost::filesystem::path(//server/share/file.txt).has_root_name() 1
boost::filesystem::path(\\server\share\file.txt).has_root_name() 1

Or to put it differently, std::filesystem doesn't seem to care either way while
Boost recognizes both.

Note that __CYGWIN__ is not defined with the compiler from MXE! I'm not
compiling on Windows. This is a cross-compiler, from Linux to Windows. What is
defined are things such as:

[0 mosu@sweet-chili ~] x86_64-w64-mingw32.static-g++ -dM -E -x c++ - <
/dev/null | sort | grep -E 'WINNT|WIN(32|64)|MINGW'
#define __MINGW32__ 1
#define __MINGW64__ 1
#define __WIN32 1
#define __WIN32__ 1
#define _WIN32 1
#define WIN32 1
#define __WIN64 1
#define __WIN64__ 1
#define _WIN64 1
#define WIN64 1
#define __WINNT 1
#define __WINNT__ 1
#define WINNT 1

Reply via email to