<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Exception thrown from a method marked noexcept"
href="https://bugs.llvm.org/show_bug.cgi?id=35078">35078</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Exception thrown from a method marked noexcept
</td>
</tr>
<tr>
<th>Product</th>
<td>libc++
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>All Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>Juan.Arrieta@nablazerolabs.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=19341" name="attach_19341" title="Minimal code to reproduce the example">attachment 19341</a> <a href="attachment.cgi?id=19341&action=edit" title="Minimal code to reproduce the example">[details]</a></span>
Minimal code to reproduce the example
Overview:
An exception of type `filesystem_error` is thrown when calling the method
`recursive_directory_iterator::increment(error_code&) noexcept` on an iterator
pointing to a directory without `execute` permission. This leads to an
inability of catching the exception, and a termination of the program via
`SIGABRT` (in macOS).
Steps to Reproduce:
In macOS:
1. mkdir fail
2. touch fail/empty
3. chmod -x fail
4. clang++ minimal.cpp -std=c++17 -lc++experimental
5. ./a.out fail/
Actual Results:
"fail/empty"
about to increment iterator
libc++abi.dylib: terminating with uncaught exception of type
std::experimental::filesystem::v1::filesystem_error:
std::experimental::filesystem::posix_stat: Permission denied
Abort trap: 6
Expected Results:
A line similar to the following one:
Error [some error code]: [some error message]
Build Date and Hardware:
October 25, 2017 / macOS High Sierra 10.13.
Additional Information:
Compile companion program as:
clang++ minimal.cpp -std=c++17 -lc++experimental -save-temps
Version Used:
clang++ --version
clang version 6.0.0 (<a href="http://llvm.org/git/clang.git">http://llvm.org/git/clang.git</a>
fbbb8c17f50e6bb450a12965d30ac47a12c9aa58) (<a href="http://llvm.org/git/llvm.git">http://llvm.org/git/llvm.git</a>
965aad0dee88dcaef11b887d8f8cc905ca43cfab)
Target: x86_64-apple-darwin17.0.0
Thread model: posix
InstalledDir: /usr/local/bin
Problem Location:
Line 2,063 in `include/experimental/filesystem` defines:
recursive_directory_iterator& increment(error_code& __ec) _NOEXCEPT
{ return __increment(&__ec); }
and line 2,098 in the same file declares:
recursive_directory_iterator& __increment(error_code *__ec=nullptr);
Implementation is in line 204 of
`src/experimental/filesystem/directory_iterator.cpp`:
directory_iterator& directory_iterator::__increment(error_code *ec)
{
_LIBCPP_ASSERT(__imp_, "Attempting to increment an invalid
iterator");
std::error_code m_ec;
if (!__imp_->advance(m_ec)) {
__imp_.reset();
if (m_ec)
set_or_throw(m_ec, ec, "directory_iterator::operator++()");
} else {
if (ec) ec->clear();
}
return *this;
}
Given that a noexcept(true) method throws an exception, the application
terminates
via `SIGABRT` after `__cxa_rethrow`.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>