www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18134] New: BitArray <<= broken when length % 32 = 0

https://issues.dlang.org/show_bug.cgi?id=18134

          Issue ID: 18134
           Summary: BitArray <<= broken when length % 32 = 0
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: simen.kjaras gmail.com

unittest
{
    import std.bitmanip : BitArray;
    import std.range : repeat;
    import std.array : array;
    BitArray ba = true.repeat(64).array;
    ba >>= 1;
    assert((cast(uint[])ba)[$-1] == 0x7FFF_FFFF);
}

When a BitArray covers exactly 32, 64, 96 and so on number of bits, the bit
shifting operation fills the last word with zeroes. The test above should pass,
but doesn't.

--
Dec 27 2017