C++ Logo


Advanced search

Re: fs::path appenders have inconsistent behavior for UNC paths between OSes

From: Andrey Semashev <andrey.semashev_at_[hidden]>
Date: Fri, 5 Nov 2021 04:58:57 +0300
On 11/5/21 04:41, Thiago Macieira via Std-Discussion wrote:
> On Thursday, 4 November 2021 15:41:17 PDT Andrey Semashev via Std-Discussion
> wrote:
>> Besides the difference in behavior, the result of "/bar" seems
>> unexpected, as appending a path starting with a root directory is
>> expected to be rebased on top of the source's root name.
>> My question is, is this behavior intentional or is this a defect? If it
>> is intentional, what is the rationale?
> It seems to me that you explained the rationale in your own email.
> The operator/ will discard the left side if the right side is an absolute
> path. Since "/bar" is an absolute path on POSIX systems, then the result of
> anything / "/bar"
> is
> "/bar"

That's not a rationale, it's a consequence of the specification. I'm
interested in the motivation for the specification being written this
way (if it was written so intentionally, with respect to the case I

To me, the check for the appended path being absolute seems superfluous.
Removing it fixes the test case I presented while it also seems to
introduce no new regressions. The spec already checks the root name and
root directory in the following steps, so eventually the algorithm still
produces expected results in non-UNC cases.

Received on 2021-11-04 20:59:03