[LLVMbugs] [Bug 19663] New: bitset ++operator generates invalid end

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue May 6 07:30:09 PDT 2014


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

            Bug ID: 19663
           Summary: bitset ++operator generates invalid end
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: Erik.Verbruggen at Me.com
                CC: llvmbugs at cs.uiuc.edu, mclow.lists at gmail.com
    Classification: Unclassified

The following program fails with an assertion:

#include <vector>
#include <cassert>
#include <algorithm>

int main()
{
    std::vector<bool> bits;
    bits.resize(6 * 64, false);
    const size_t thePlace = 375;
    const size_t start = thePlace + 1;
    bits[thePlace] = true;
    std::vector<bool>::iterator i = std::find(bits.begin() + start, bits.end(),
true);
    assert(i == bits.end());
    return i - bits.begin();
}


The expected result is that i should equal end(). It only fails when the bit
vector size is a whole multiple of the word size (64 bit for me).

Looking at i, what surprised me a bit is that __ctz_ (the bit in the word
pointed to) is 64, while for end() it's 0. I suspect that the ++operator
produces the wrong value for "the end" in this case.

-- 
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/20140506/4defa95d/attachment.html>


More information about the llvm-bugs mailing list