<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 - _LIBCPP_DEBUG=1 std::string::iterator thinks the end iterator is "non-dereferenceable""
href="https://bugs.llvm.org/show_bug.cgi?id=44400">44400</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>_LIBCPP_DEBUG=1 std::string::iterator thinks the end iterator is "non-dereferenceable"
</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>arthur.j.odwyer@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
</td>
</tr></table>
<p>
<div>
<pre><a class="bz_bug_link
bz_status_NEW "
title="NEW - _LIBCPP_DEBUG=1 std::transform in-place: abort() (Attempted to dereference a non-dereferenceable iterator)"
href="show_bug.cgi?id=41274">Bug 41274</a> may be related somehow.
// <a href="https://godbolt.org/z/PeZLZi">https://godbolt.org/z/PeZLZi</a>
int main(int, char**)
{
std::string In2("abcd/efg");
std::string::iterator it = In2.end();
assert(*it == '\0'); // FAILS
(void) fs::u8path(In2.begin()); // FAILS
}
For something like a std::vector, the "end()" iterator indeed would be
non-dereferenceable. But for a std::string, the "end()" iterator points to the
null terminator, which is a valid character. There is at least one libc++ test
that relies on being able to dereference the "end()" iterator of a std::string:
libcxx/test/std/input.output/filesystems/class.path/path.nonmember/path.factory.pass.cpp
Possible resolutions include:
- Make the one-character fix to basic_string::__dereferenceable (change < to
<=).
- Rewrite `fs::u8path` so that it doesn't try to read the null terminator.
(This is physically impossible, I think?)
- Decide that the current "path.factory.pass.cpp" has UB and eliminate it from
the test suite (perhaps with accompanying LWG issue about this trap for the
unwary).</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>