Boost C++ Libraries: Ticket #13217: remove_all(const path& p, system::error_code& ec) is not supposed to throw filesystem_error, but still can https://svn.boost.org/trac10/ticket/13217 <p> I will be submitting a github pull request in association with this ticket. </p> <p> According to the documentation, uintmax_t remove_all(const path&amp; p, system::error_code&amp; ec) is not supposed to throw filesystem_error. However, when the directory_iterator used in the loop inside the implementation helper function remove_all_aux() is incremented, it's not done in a way that considers the ec argument. So, when incrementing the iterator fails, the operator++() on the directory_iterator throws, which leads to remove_all() incorrectly throwing. </p> <p> To fix this, it seems that one can take the same approach as the recent changes for Fix <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7307" title="#7307: Bugs: boost::filesystem::remove_all(dirname,ec) throws on write protected ... (closed: fixed)">#7307</a> (commit 4e4374336c640c2717f6a1b168406e11bdf7d6f1) and replace the ++itr call in the loop with an explicit call to either directory_iterator::increment(system::error_code&amp; ec) whenever an ec argument is in effect. This should prevent remove_all() from throwing in such cases and thus allow it to conform to its interface specification. </p> <p> BTW I also found these possibly related tickets in Trac: </p> <ul><li><a class="new ticket" href="https://svn.boost.org/trac10/ticket/10380" title="#10380: Bugs: filesystem directory iterator throws on increment (new)">#10380</a> </li><li><a class="new ticket" href="https://svn.boost.org/trac10/ticket/12640" title="#12640: Bugs: is_empty and remove_all may throw even when called with error_code&amp; ... (new)">#12640</a> </li></ul> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13217 Trac 1.4.3 Brad Spencer <bspencer@…> Fri, 22 Sep 2017 14:37:09 GMT <link>https://svn.boost.org/trac10/ticket/13217#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13217#comment:1</guid> <description> <p> <a class="ext-link" href="https://github.com/boostorg/filesystem/pull/53"><span class="icon">​</span>https://github.com/boostorg/filesystem/pull/53</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Thu, 10 May 2018 10:57:57 GMT</pubDate> <title>component changed; owner set https://svn.boost.org/trac10/ticket/13217#comment:2 https://svn.boost.org/trac10/ticket/13217#comment:2 <ul> <li><strong>owner</strong> set to <span class="trac-author">Beman Dawes</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">filesystem</span> </li> </ul> Ticket