MinGW currently has bugs with UNC paths in C++ filesystem library. MSVC, Clang-CL, oneAPI work correctly.
A convenience script runs the tests from the oneAPI command prompt (or MSVC if oneAPI not available).
cmake -P main.cmake
cl /std:c++17 test_unc.cpp && test_unc.exe
PASSED: path: "\\\\server\\share\\path\\" == "\\\\server\\share\\path\\"
PASSED: path: "\\\\host\\a\\c" == "\\\\host\\a\\c"
PASSED: string: \\host\a\c == \\host\a\c
PASSED: generic string: //host/a/c == //host/a/c
OK: UNC tests passed
g++ --version && g++ test_unc.cpp && ./a.exe
g++.exe (Rev3, Built by MSYS2 project) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
PASSED: path: "\\server\\share\\path\\" == "\\server\\share\\path\\"
PASSED: path: "\\host\\a\\c" == "\\\\host\\a\\c"
FAILED: string: \host\a\c != \\host\a\c
FAILED: generic string: /host/a/c != //host/a/c
FAILED: UNC tests
clang++ --version && clang++ test_unc.cpp && ./a.exe
clang version 17.0.6
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: C:/msys64/mingw64/bin
PASSED: path: "\\server\\share\\path\\" == "\\server\\share\\path\\"
PASSED: path: "\\host\\a\\c" == "\\\\host\\a\\c"
FAILED: string: \host\a\c != \\host\a\c
FAILED: generic string: /host/a/c != //host/a/c
FAILED: UNC tests
ICX (MSVC-like) driver
icx test_unc.cpp && test_unc.exe
Intel(R) oneAPI DPC++/C++ Compiler 2024.0.0 (2024.0.0.20231017)
Target: x86_64-pc-windows-msvc
Thread model: posix
PASSED: path: "\\\\server\\share\\path\\" == "\\\\server\\share\\path\\"
PASSED: path: "\\\\host\\a\\c" == "\\\\host\\a\\c"
PASSED: string: \\host\a\c == \\host\a\c
PASSED: generic string: //host/a/c == //host/a/c
OK: UNC tests passed
ICPX (GNU-like) driver
icpx --version && icpx test_unc.cpp && a.exe
Intel(R) oneAPI DPC++/C++ Compiler 2024.0.0 (2024.0.0.20231017)
Target: x86_64-pc-windows-msvc
Thread model: posix
PASSED: path: "\\\\server\\share\\path\\" == "\\\\server\\share\\path\\"
PASSED: path: "\\\\host\\a\\c" == "\\\\host\\a\\c"
PASSED: string: \\host\a\c == \\host\a\c
PASSED: generic string: //host/a/c == //host/a/c
OK: UNC tests passed