<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2722: equivalent incorrectly specifies throws clause</title>
<meta property="og:title" content="Issue 2722: equivalent incorrectly specifies throws clause">
<meta property="og:description" content="C++ library issue. Status: C++17">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2722.html">
<meta property="og:type" content="website">
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
<meta property="og:image:alt" content="C++ logo">
<style>
  p {text-align:justify}
  li {text-align:justify}
  pre code.backtick::before { content: "`" }
  pre code.backtick::after { content: "`" }
  blockquote.note
  {
    background-color:#E0E0E0;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 1px;
    padding-bottom: 1px;
  }
  ins {background-color:#A0FFA0}
  del {background-color:#FFA0A0}
  table.issues-index { border: 1px solid; border-collapse: collapse; }
  table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
  table.issues-index td { padding: 4px; border: 1px solid; }
  table.issues-index td:nth-child(1) { text-align: right; }
  table.issues-index td:nth-child(2) { text-align: left; }
  table.issues-index td:nth-child(3) { text-align: left; }
  table.issues-index td:nth-child(4) { text-align: left; }
  table.issues-index td:nth-child(5) { text-align: center; }
  table.issues-index td:nth-child(6) { text-align: center; }
  table.issues-index td:nth-child(7) { text-align: left; }
  table.issues-index td:nth-child(5) span.no-pr { color: red; }
  @media (prefers-color-scheme: dark) {
     html {
        color: #ddd;
        background-color: black;
     }
     ins {
        background-color: #225522
     }
     del {
        background-color: #662222
     }
     a {
        color: #6af
     }
     a:visited {
        color: #6af
     }
     blockquote.note
     {
        background-color: rgba(255, 255, 255, .10)
     }
  }
</style>
</head>
<body>
<hr>
<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#C++17">C++17</a> status.</em></p>
<h3 id="2722"><a href="lwg-defects.html#2722">2722</a>. <code>equivalent</code> incorrectly specifies throws clause</h3>
<p><b>Section:</b> 31.12.13.13 <a href="https://wg21.link/fs.op.equivalent">[fs.op.equivalent]</a> <b>Status:</b> <a href="lwg-active.html#C++17">C++17</a>
 <b>Submitter:</b> Eric Fiselier <b>Opened:</b> 2016-05-28 <b>Last modified:</b> 2017-07-30</p>
<p><b>Priority: </b>3
</p>
<p><b>View all other</b> <a href="lwg-index.html#fs.op.equivalent">issues</a> in [fs.op.equivalent].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++17">C++17</a> status.</p>
<p><b>Discussion:</b></p>
<p>
The spec for <code>equivalent</code> has a throws clause which reads: [fs.op.equivalent]/5
</p>
<blockquote>
<p>
<i>Throws:</i> <code>filesystem_error</code> if <code>(!exists(s1) &amp;&amp; !exists(s2)) || (is_other(s1) 
&amp;&amp; is_other(s2))</code>, otherwise as specified in Error reporting (27.10.7).
</p>
</blockquote>
<p>
This explicit requirement to throw is incorrect for the <code>equivalent</code> overload which takes an <code>error_code</code>.
</p>

<p><strong>Previous resolution [SUPERSEDED]:</strong></p>
<blockquote class="note">
<p>This wording is relative to N4582.</p>
<ol>
<li><p>Modify 31.12.13.13 <a href="https://wg21.link/fs.op.equivalent">[fs.op.equivalent]</a> as follows:</p>

<blockquote>
<pre>
bool equivalent(const path&amp; p1, const path&amp; p2);
bool equivalent(const path&amp; p1, const path&amp; p2, error_code&amp; ec) noexcept;
</pre>
<blockquote>
<p>
-1- <i>Effects:</i> Determines <code>file_status s1</code> and <code>s2</code>, as if by <code>status(p1)</code> and 
<code>status(p2)</code>, respectively.
<p/>
-2- <i>Returns:</i> <ins>If <code>(!exists(s1) &amp;&amp; !exists(s2)) || (is_other(s1) &amp;&amp; is_other(s2))</code> 
an error is reported (31.12.5 <a href="https://wg21.link/fs.err.report">[fs.err.report]</a>). Otherwise</ins> <code>true</code>, if <code>s1 == s2</code> and 
<code>p1</code> and <code>p2</code> resolve to the same file system entity, else <code>false</code>. The signature with argument 
<code>ec</code> returns <code>false</code> if an error occurs.
<p/>
-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 <code>stat</code> structure,
obtained as if by <code>stat()</code> for the two paths, having equal <code>st_dev</code> values and equal <code>st_ino</code> values.
<p/>
-4- <i>Throws:</i> <del><code>filesystem_error</code> if <code>(!exists(s1) &amp;&amp; !exists(s2)) || (is_other(s1) &amp;&amp; 
is_other(s2))</code>, otherwise a</del><ins>A</ins>s specified in <del>E</del><ins>e</ins>rror reporting 
(31.12.5 <a href="https://wg21.link/fs.err.report">[fs.err.report]</a>).
</p>
</blockquote>
</blockquote>
</li>
</ol>
</blockquote>

<p><i>[2016-06 Oulu &mdash; Daniel provides wording improvements]</i></p>

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

<p><i>[2016-08 Chicago]</i></p>

<p>Wed AM: Move to Tentatively Ready</p>


<p id="res-2722"><b>Proposed resolution:</b></p>
<p>This wording is relative to N4594.</p>
<ol>
<li><p>Modify 31.12.13.13 <a href="https://wg21.link/fs.op.equivalent">[fs.op.equivalent]</a> as follows:</p>

<blockquote>
<pre>
bool equivalent(const path&amp; p1, const path&amp; p2);
bool equivalent(const path&amp; p1, const path&amp; p2, error_code&amp; ec) noexcept;
</pre>
<blockquote>
<p>
-1- Let <code>s1</code> and <code>s2</code> be <code>file_status</code>s, determined as if by <code>status(p1)</code> and <code>status(p2)</code>, respectively.
<p/>
-2- <i>Effects:</i> Determines <code>s1</code> and <code>s2</code>. <ins>If <code>(!exists(s1) &amp;&amp; !exists(s2)) || 
(is_other(s1) &amp;&amp; is_other(s2))</code> an error is reported (31.12.5 <a href="https://wg21.link/fs.err.report">[fs.err.report]</a>).</ins>
<p/>
-3- <i>Returns:</i> <code>true</code>, if <code>s1 == s2</code> and 
<code>p1</code> and <code>p2</code> resolve to the same file system entity, else <code>false</code>. The signature with argument 
<code>ec</code> returns <code>false</code> if an error occurs.
<p/>
-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 <code>stat</code> structure,
obtained as if by <code>stat()</code> for the two paths, having equal <code>st_dev</code> values and equal <code>st_ino</code> values.
<p/>
-5- <i>Throws:</i> <del><code>filesystem_error</code> if <code>(!exists(s1) &amp;&amp; !exists(s2)) || (is_other(s1) &amp;&amp; 
is_other(s2))</code>, otherwise a</del><ins>A</ins>s specified in <del>E</del><ins>e</ins>rror reporting 
(31.12.5 <a href="https://wg21.link/fs.err.report">[fs.err.report]</a>).
</p>
</blockquote>
</blockquote>
</li>
</ol>





</body>
</html>
