[Issue 11015] New: BitArray.opCom is invalid on 64 bit machines
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Sep 12 01:33:04 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11015
Summary: BitArray.opCom is invalid on 64 bit machines
Product: D
Version: unspecified
Platform: x86_64
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: nikolay.v.belov at gmail.com
--- Comment #0 from nbelov <nikolay.v.belov at gmail.com> 2013-09-12 01:33:01 PDT ---
result.ptr[dim - 1] &= ~(~0 << (len & (bitsPerSizeT-1)));
On 64 bit machine 0 - is 32 bit value, but bitsPerSizeT == 64.
Need add cast 0 to size_t:
result.ptr[dim - 1] &= ~(~cast(size_t)0 << (len & (bitsPerSizeT-1)));
Test:
foreach (len; 1 .. 256)
{
foreach (i; 0 .. len)
{
BitArray a1; a1.length = len;
foreach (j; 0 .. len)
{
a1[j] = true;
}
a1[i] = false;
BitArray a2; a2.length = len;
a2[i] = true;
BitArray a3 = ~a2;
assert(a3 == a1);
}
}
For reproduce you need fix opEquals (see bug #10948:
http://d.puremagic.com/issues/show_bug.cgi?id=10948)
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list