<html>
<head>
<base href="http://llvm.org/bugs/" />
</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 --- - Unexpected iterator value returned by std::find specialization on std::vector<bool>"
href="http://llvm.org/bugs/show_bug.cgi?id=16816">16816</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Unexpected iterator value returned by std::find specialization on std::vector<bool>
</td>
</tr>
<tr>
<th>Product</th>
<td>libc++
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</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>hhinnant@apple.com
</td>
</tr>
<tr>
<th>Reporter</th>
<td>andyw@emnetsoftware.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=10997" name="attach_10997" title="Source for console application showing problem in std::find with std::vector<bool>.">attachment 10997</a> <a href="attachment.cgi?id=10997&action=edit" title="Source for console application showing problem in std::find with std::vector<bool>.">[details]</a></span>
Source for console application showing problem in std::find with
std::vector<bool>.
I'm using std::find on an std::vector<bool> instance. I'm finding that the
iterator returned is not what I expect (actually it's out of range). The
essence of the code sample is:
std::vector<bool> b(5,false);
auto it = std::find(b.begin()+1, b.end());
// 'it' is now positioned at b.begin() + 64! But b.size()==5!
It looks like the std::find(..) specialization for std::vector<bool> is broken
under certain conditions (certain sizes of std::vector<bool>?).
The full sample is attached as a single source file that can be compiled as a
console application. I've also compared the result using an online compiler
(GCC 4.8? libstdc++?), and this can be found at:
<a href="http://ideone.com/RyI8sJ">http://ideone.com/RyI8sJ</a>
I'm using libcxx version found in XCode 4.6.3 on OSX (_LIBCPP_VERSION = 1101).
I using Clang compiler with settings:
clang++ -std=c++11 -stdlib=libc++ main.cpp</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>