diff --git a/stl/inc/filesystem b/stl/inc/filesystem index 7d838ea2d17..b9cc15336ea 100644 --- a/stl/inc/filesystem +++ b/stl/inc/filesystem @@ -3013,17 +3013,15 @@ namespace filesystem { // calls GetFullPathNameW _Ec.clear(); // for exception safety path _Result; - if (!_Input._Text.empty()) { - _Result._Text.resize(__std_fs_max_path); - for (;;) { - const auto _Requested_size = static_cast(_Result._Text.size()); - const auto _Full_path_result = - __std_fs_get_full_path_name(_Input._Text.c_str(), _Requested_size, _Result._Text.data()); - _Result._Text.resize(_Full_path_result._Size); - if (_Full_path_result._Size < _Requested_size) { - _Ec = _Make_ec(_Full_path_result._Error); - break; - } + _Result._Text.resize(__std_fs_max_path); + for (;;) { + const auto _Requested_size = static_cast(_Result._Text.size()); + const auto _Full_path_result = + __std_fs_get_full_path_name(_Input._Text.c_str(), _Requested_size, _Result._Text.data()); + _Result._Text.resize(_Full_path_result._Size); + if (_Full_path_result._Size < _Requested_size) { + _Ec = _Make_ec(_Full_path_result._Error); + break; } } return _Result; diff --git a/tests/libcxx/expected_results.txt b/tests/libcxx/expected_results.txt index 80d306a728f..71b40407f77 100644 --- a/tests/libcxx/expected_results.txt +++ b/tests/libcxx/expected_results.txt @@ -736,6 +736,9 @@ std/iterators/iterator.requirements/iterator.assoc.types/readable.traits/indirec # Not analyzed, likely bogus test. constexpr fails with "vector iterators incompatible". std/ranges/range.adaptors/range.join.with/range.join.with.iterator/ctor.default.pass.cpp FAIL +# libc++ treats `fs::absolute("", ec)` as a success case, whereas we emit an error and return an empty `path`. +std/input.output/filesystems/fs.op.funcs/fs.op.absolute/absolute.pass.cpp FAIL + # Problems in this test: # - Clang does not trap on ARM64, but MSVC does. # - The test inspects `__x86_64__` and `__i386__`, which MSVC doesn't define. @@ -1140,9 +1143,6 @@ std/input.output/filesystems/class.path/path.member/path.generic.obs/generic_str # Not analyzed. Assertion failed: std::equal(p.begin(), p.end(), TC.elements.begin(), ComparePathExact()) std/input.output/filesystems/class.path/path.member/path.decompose/path.decompose.pass.cpp FAIL -# Not analyzed. Assertion failed: ret.is_absolute() -std/input.output/filesystems/fs.op.funcs/fs.op.absolute/absolute.pass.cpp FAIL - # Not analyzed. Assertion failed: ret == TC.p std/input.output/filesystems/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp FAIL diff --git a/tests/std/tests/P0218R1_filesystem/test.cpp b/tests/std/tests/P0218R1_filesystem/test.cpp index de836655bc4..edd4b60ce03 100644 --- a/tests/std/tests/P0218R1_filesystem/test.cpp +++ b/tests/std/tests/P0218R1_filesystem/test.cpp @@ -1537,7 +1537,13 @@ void test_absolute() { longPath.resize(260); expect_absolute(longPath, longPath); - expect_absolute({}, {}); + EXPECT(absolute(L"", ec).empty()); + if (ec.value() != 123) { + wcerr << L"Warning: Expected absolute on an empty path to report ERROR_INVALID_NAME, " + L"but it reported " + << ec.value() << L"\n"; + } + EXPECT(ec.category() == system_category()); } void test_canonical() {