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

### 2722. `equivalent` incorrectly specifies throws clause

Section: 31.12.13.13 [fs.op.equivalent] Status: C++17 Submitter: Eric Fiselier Opened: 2016-05-28 Last modified: 2017-07-30

Priority: 3

View all other issues in [fs.op.equivalent].

View all issues with C++17 status.

Discussion:

The spec for `equivalent` has a throws clause which reads: [fs.op.equivalent]/5

> Throws: `filesystem_error` if `(!exists(s1) && !exists(s2)) || (is_other(s1) && is_other(s2))`, otherwise as specified in Error reporting (27.10.7).

This explicit requirement to throw is incorrect for the `equivalent` overload which takes an `error_code`.

Previous resolution [SUPERSEDED]:

> This wording is relative to N4582.

> 1. Modify 31.12.13.13 [fs.op.equivalent] as follows:

>    >     bool equivalent(const path& p1, const path& p2);
>    >     bool equivalent(const path& p1, const path& p2, error_code& ec) noexcept;

>    > > -1- Effects: Determines `file_status s1` and `s2`, as if by `status(p1)` and `status(p2)`, respectively.

>    > > -2- Returns: If `(!exists(s1) && !exists(s2)) || (is_other(s1) && is_other(s2))` an error is reported (31.12.5 [fs.err.report]). Otherwise `true`, if `s1 == s2` and `p1` and `p2` resolve to the same file system entity, else `false`. The signature with argument `ec` returns `false` if an error occurs.

>    > > -3- Two paths are considered to resolve to the same file system entity if two candidate entities reside on the same device at the same location. This is determined as if by the values of the POSIX `stat` structure, obtained as if by `stat()` for the two paths, having equal `st_dev` values and equal `st_ino` values.

>    > > -4- Throws: `filesystem_error` if `(!exists(s1) && !exists(s2)) || (is_other(s1) && is_other(s2))`, otherwise a As specified in E error reporting (31.12.5 [fs.err.report]).

[2016-06 Oulu — Daniel provides wording improvements]

mc: do we have an error reporting clause?
jw: there is no such clause
gr: it should go into the effects clause
dk: we have the same issue for `file_size`
dk: the right place is the effects clause

[2016-08 Chicago]

Wed AM: Move to Tentatively Ready

Proposed resolution:

This wording is relative to N4594.

1. Modify 31.12.13.13 [fs.op.equivalent] as follows:

   >     bool equivalent(const path& p1, const path& p2);
   >     bool equivalent(const path& p1, const path& p2, error_code& ec) noexcept;

   > > -1- Let `s1` and `s2` be `file_status`s, determined as if by `status(p1)` and `status(p2)`, respectively.

   > > -2- Effects: Determines `s1` and `s2`. If `(!exists(s1) && !exists(s2)) || (is_other(s1) && is_other(s2))` an error is reported (31.12.5 [fs.err.report]).

   > > -3- Returns: `true`, if `s1 == s2` and `p1` and `p2` resolve to the same file system entity, else `false`. The signature with argument `ec` returns `false` if an error occurs.

   > > -4- Two paths are considered to resolve to the same file system entity if two candidate entities reside on the same device at the same location. This is determined as if by the values of the POSIX `stat` structure, obtained as if by `stat()` for the two paths, having equal `st_dev` values and equal `st_ino` values.

   > > -5- Throws: `filesystem_error` if `(!exists(s1) && !exists(s2)) || (is_other(s1) && is_other(s2))`, otherwise a As specified in E error reporting (31.12.5 [fs.err.report]).