<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3014: More noexcept issues with filesystem operations</title>
<meta property="og:title" content="Issue 3014: More noexcept issues with filesystem operations">
<meta property="og:description" content="C++ library issue. Status: C++20">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3014.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="3014"><a href="lwg-defects.html#3014">3014</a>. More <code>noexcept</code> issues with filesystem operations</h3>
<p><b>Section:</b> 31.12.13.5 <a href="https://wg21.link/fs.op.copy.file">[fs.op.copy.file]</a>, 31.12.13.7 <a href="https://wg21.link/fs.op.create.directories">[fs.op.create.directories]</a>, 31.12.13.32 <a href="https://wg21.link/fs.op.remove.all">[fs.op.remove.all]</a> <b>Status:</b> <a href="lwg-active.html#C++20">C++20</a>
 <b>Submitter:</b> Tim Song <b>Opened:</b> 2017-08-23 <b>Last modified:</b> 2021-06-06</p>
<p><b>Priority: </b>Not Prioritized
</p>
<p><b>View all other</b> <a href="lwg-index.html#fs.op.copy.file">issues</a> in [fs.op.copy.file].</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>
<code>create_directories</code> may need to create temporary <code>path</code>s, and <code>remove_all</code> may need to create temporary
<code>path</code>s and/or <code>directory_iterator</code>s. These operations may require a potentially throwing memory allocation.
<p/>
Implementations of <code>copy_file</code> may wish to dynamically allocate the buffer used for copying when the underlying OS
doesn't supply a copy API directly. This can happen indirectly, e.g., by using <code>&lt;fstream&gt;</code> facilities to
perform the copying without supplying a custom buffer. Unless LWG wishes to prohibit using a dynamically allocated buffer
in this manner, the <code>noexcept</code> should be removed.
</p>

<p><i>[2017-11 Albuquerque Wednesday night issues processing]</i></p>

<p>Moved to Ready</p>
<p><i>[2018-3-17 Adopted in Jacksonville]</i></p>



<p id="res-3014"><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.4 <a href="https://wg21.link/fs.filesystem.syn">[fs.filesystem.syn]</a>, header <code>&lt;filesystem&gt;</code> synopsis, as indicated:</p>
<blockquote>
<pre>
namespace std::filesystem {

  [&hellip;]

  bool copy_file(const path&amp; from, const path&amp; to);
  bool copy_file(const path&amp; from, const path&amp; to, error_code&amp; ec) <del>noexcept</del>;
  bool copy_file(const path&amp; from, const path&amp; to, copy_options option);
  bool copy_file(const path&amp; from, const path&amp; to, copy_options option,
                 error_code&amp; ec) <del>noexcept</del>;

  [&hellip;]

  bool create_directories(const path&amp; p);
  bool create_directories(const path&amp; p, error_code&amp; ec) <del>noexcept</del>;

  [&hellip;]

  uintmax_t remove_all(const path&amp; p);
  uintmax_t remove_all(const path&amp; p, error_code&amp; ec) <del>noexcept</del>;

  [&hellip;]
}
</pre>
</blockquote>
</li>

<li><p>Edit  [fs.op.copy_file] as indicated:</p>
<blockquote>
<pre>
bool copy_file(const path&amp; from, const path&amp; to);
bool copy_file(const path&amp; from, const path&amp; to, error_code&amp; ec) <del>noexcept</del>;
</pre>
<blockquote>
<p>
-1- <i>Returns:</i> [&hellip;]
<p/>
-2- <i>Throws:</i> [&hellip;]
</p>
</blockquote>
<pre>
bool copy_file(const path&amp; from, const path&amp; to, copy_options options);
bool copy_file(const path&amp; from, const path&amp; to, copy_options options,
               error_code&amp; ec) <del>noexcept</del>;
</pre>
<blockquote>
<p>
-3- <i>Requires:</i> [&hellip;]
<p/>
-4- <i>Effects:</i> [&hellip;]
<p/>
-5- <i>Returns:</i> [&hellip;]
<p/>
-6- <i>Throws:</i> [&hellip;]
<p/>
-7- <i>Complexity:</i> [&hellip;]
</p>
</blockquote>
</blockquote>
</li>

<li><p>Edit  [fs.op.create_directories] as indicated:</p>
<blockquote>
<pre>
bool create_directories(const path&amp; p);
bool create_directories(const path&amp; p, error_code&amp; ec) <del>noexcept</del>;
</pre>
<blockquote>
<p>
-1- <i>Effects:</i> [&hellip;]
<p/>
-2- <i>Postconditions:</i> [&hellip;]
<p/>
-3- <i>Returns:</i> [&hellip;]
<p/>
-4- <i>Throws:</i> [&hellip;]
<p/>
-5- <i>Complexity:</i> [&hellip;]
</p>
</blockquote>
</blockquote>
</li>
<li><p>Edit  [fs.op.remove_all] as indicated:</p>
<blockquote>
<pre>
uintmax_t remove_all(const path&amp; p);
uintmax_t remove_all(const path&amp; p, error_code&amp; ec) <del>noexcept</del>;
</pre>
<blockquote>
<p>
-1- <i>Effects:</i> [&hellip;]
<p/>
-2- <i>Postconditions:</i> [&hellip;]
<p/>
-3- <i>Returns:</i> [&hellip;]
<p/>
-4- <i>Throws:</i> [&hellip;]
</p>
</blockquote>
</blockquote>
</li>
</ol>




</body>
</html>
