[LLVMbugs] [Bug 16816] New: Unexpected iterator value returned by std::find specialization on std::vector<bool>

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Aug 7 00:58:58 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=16816

            Bug ID: 16816
           Summary: Unexpected iterator value returned by std::find
                    specialization on std::vector<bool>
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: hhinnant at apple.com
          Reporter: andyw at emnetsoftware.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 10997
  --> http://llvm.org/bugs/attachment.cgi?id=10997&action=edit
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:
  http://ideone.com/RyI8sJ

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

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130807/887c17c4/attachment.html>


More information about the llvm-bugs mailing list