<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3015: copy_options::unspecified underspecified</title>
<meta property="og:title" content="Issue 3015: copy_options::unspecified underspecified">
<meta property="og:description" content="C++ library issue. Status: C++20">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3015.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++20">C++20</a> status.</em></p>
<h3 id="3015"><a href="lwg-defects.html#3015">3015</a>. <code>copy_options::<i>unspecified</i></code> underspecified</h3>
<p><b>Section:</b> 31.12.13.4 <a href="https://wg21.link/fs.op.copy">[fs.op.copy]</a> <b>Status:</b> <a href="lwg-active.html#C++20">C++20</a>
 <b>Submitter:</b> Tim Song <b>Opened:</b> 2017-08-24 <b>Last modified:</b> 2021-02-25</p>
<p><b>Priority: </b>3
</p>
<p><b>View all other</b> <a href="lwg-index.html#fs.op.copy">issues</a> in [fs.op.copy].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++20">C++20</a> status.</p>
<p><b>Discussion:</b></p>
<p>
31.12.13.4 <a href="https://wg21.link/fs.op.copy">[fs.op.copy]</a>/4.8.2 says in the copy-a-directory case <code>filesystem::copy</code> performs:
<blockquote>
<pre>
for (const directory_entry&amp; x : directory_iterator(from))
  copy(x.path(), to/x.path().filename(), options | copy_options::<i>unspecified</i>);
</pre>
</blockquote>
<p/>
Presumably this does not actually mean that the implementation is free to set whatever <code>copy_option</code> element it wishes 
(<code>directories_only</code>? <code>recursive</code>? <code>create_hard_links</code>?), or <code>none</code> at all, or &ndash; since 
unspecified behavior corresponds to the nondeterministic aspects of the abstract machine (6.10.1 <a href="https://wg21.link/intro.execution">[intro.execution]</a>/3) 
&ndash; a nondeterministically picked element for every iteration of the loop. That would be outright insane.
<p/>
I'm fairly sure that what's intended here is to set an otherwise-unused bit in <code>options</code> so as to prevent recursion in the <code>options == copy_options::none</code> case.
</p>

<p><i>[2017-11-08]</i></p>

<p>Priority set to 3 after five votes on the mailing list</p>

<strong>Previous resolution: [SUPERSEDED]</strong>
<blockquote class="note">
<p>This wording is relative to <a href="https://wg21.link/n4687">N4687</a>.</p>

<ol>
<li><p>Edit 31.12.13.4 <a href="https://wg21.link/fs.op.copy">[fs.op.copy]</a> p4, bullet 4.8.2 as indicated:</p>
<blockquote>
<ol style="list-style-type: none">
<li><p>(4.7) &mdash; Otherwise, if <code>is_regular_file(f)</code>, then:</p>
<blockquote>
[&hellip;]
</blockquote>
</li>
<li><p>(4.8) &mdash; Otherwise, if</p>
<blockquote>
<blockquote><pre>
is_directory(f) &amp;&amp;
((options &amp; copy_options::recursive) != copy_options::none ||
options == copy_options::none)
</pre></blockquote>
<p>
then:
</p>
</blockquote>
<ol style="list-style-type: none">
<li><p>(4.8.1) &mdash; If <code>exists(t)</code> is <code>false</code>, then <code>create_directory(to, from)</code>.</p></li>
<li><p>(4.8.2) &mdash; Then, iterate over the files in <code>from</code>, as if by </p>
<blockquote>
<blockquote><pre>
for (const directory_entry&amp; x : directory_iterator(from))
  copy(x.path(), to/x.path().filename(), options | copy_options::<i><del>unspecified</del><ins>in-recursive-copy</ins></i>)<ins>;</ins>
</pre></blockquote>
<p>
<ins>where <code><i>in-recursive-copy</i></code> is an exposition-only bitmask element of <code>copy_options</code> that is not one of the elements in 31.12.8.3 <a href="https://wg21.link/fs.enum.copy.opts">[fs.enum.copy.opts]</a>.</ins>
</p>
</blockquote>
</li>
</ol>
</li>
<li><p>(4.9) &mdash; Otherwise, for the signature with argument <code>ec</code>, <code>ec.clear()</code>.</p></li>
<li><p>(4.10) &mdash; Otherwise, no effects.</p></li>
</ol>
</blockquote>
</li>
</ol>
</blockquote>

<p><i>[2018-1-26 issues processing telecon]</i></p>

<p>Status to 'Tentatively Ready' after striking the words 'Exposition-only' from the added text</p>
<p><i>[2018-3-17 Adopted in Jacksonville]</i></p>



<p id="res-3015"><b>Proposed resolution:</b></p>
<p>This wording is relative to <a href="https://wg21.link/n4687">N4687</a>.</p>

<ol>
<li><p>Edit 31.12.13.4 <a href="https://wg21.link/fs.op.copy">[fs.op.copy]</a> p4, bullet 4.8.2 as indicated:</p>
<blockquote>
<ol style="list-style-type: none">
<li><p>(4.7) &mdash; Otherwise, if <code>is_regular_file(f)</code>, then:</p>
<blockquote>
[&hellip;]
</blockquote>
</li>
<li><p>(4.8) &mdash; Otherwise, if</p>
<blockquote>
<blockquote><pre>
is_directory(f) &amp;&amp;
((options &amp; copy_options::recursive) != copy_options::none ||
options == copy_options::none)
</pre></blockquote>
<p>
then:
</p>
</blockquote>
<ol style="list-style-type: none">
<li><p>(4.8.1) &mdash; If <code>exists(t)</code> is <code>false</code>, then <code>create_directory(to, from)</code>.</p></li>
<li><p>(4.8.2) &mdash; Then, iterate over the files in <code>from</code>, as if by </p>
<blockquote>
<blockquote><pre>
for (const directory_entry&amp; x : directory_iterator(from))
  copy(x.path(), to/x.path().filename(), options | copy_options::<i><del>unspecified</del><ins>in-recursive-copy</ins></i>)<ins>;</ins>
</pre></blockquote>
<p>
<ins>where <code><i>in-recursive-copy</i></code> is an bitmask element of <code>copy_options</code> that is not one of the elements in 31.12.8.3 <a href="https://wg21.link/fs.enum.copy.opts">[fs.enum.copy.opts]</a>.</ins>
</p>
</blockquote>
</li>
</ol>
</li>
<li><p>(4.9) &mdash; Otherwise, for the signature with argument <code>ec</code>, <code>ec.clear()</code>.</p></li>
<li><p>(4.10) &mdash; Otherwise, no effects.</p></li>
</ol>
</blockquote>
</li>
</ol>




</body>
</html>
