This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.

3699. lexically_relative on UNC drive paths (\\?\C:\...) results in a default-constructed value

Section: 31.12.6.5.11 [fs.path.gen] Status: New Submitter: Nicole Mazzuca Opened: 2022-05-12 Last modified: 2022-05-17

Priority: 3

View all other issues in [fs.path.gen].

View all issues with New status.

Discussion:

As a resolution to LWG 3070, in path lexically_relative(const path& base) const, bullet 3.4 was added:

If: […] any filename in relative_path() or base.relative_path() can be interpreted as a root-name, […] returns path().

This resolution was correct when we have really weird paths like abc\X:\c, but the MSVC standard library implementation treats UNC drive-relative paths as:

\\?\C:\foo\bar = { root-name = \\?, root-directory = \, relative-path = C:\foo\bar }

If we were able to go back in time, we might have root-name = \\?\C:, but we can't make that change at that point without silently breaking users; therefore, we believe it would be best to instead change lexically_relative() to work around this issue.

There exists a related github issue.

I don't yet have standard wording, but I think it would be reasonable to do something like:

If relative_path().has_root_path() && base.relative_path().has_root_path(), and relative_path().root_path() == base.relative_path().root_path(), then return relative_path().lexically_relative(base.relative_path()).

[2022-05-17; Reflector poll]

Set priority to 3 after reflector poll.

Proposed resolution: