www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20240] New: BitArray inconsistently preserves bits past length

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

          Issue ID: 20240
           Summary: BitArray inconsistently preserves bits past length
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P4
         Component: phobos
          Assignee: dlang-bugzilla thecybershadow.net
          Reporter: dlang-bugzilla thecybershadow.net

//////////// test.d ///////////
import std.bitmanip;

void main()
{
    BitArray ba;

    ba.length = 1;
    ba[0] = 1;
    ba.length = 0;
    ba.length = 1;
    assert(ba[0] == 0); // OK

    ba.length = 2;
    ba[1] = 1;
    ba.length = 1;
    ba.length = 2;
    assert(ba[1] == 0); // Fail
}
///////////////////////////////

--
Sep 25 2019