← Back to index
|
Original Bugzilla link
Bug 11015 – BitArray.opCom is invalid on 64 bit machines
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
All
Creation time
2013-09-12T01:33:01Z
Last change time
2020-03-21T03:56:33Z
Keywords
pull
Assigned to
No Owner
Creator
nbelov
Comments
Comment #0
by nikolay.v.belov — 2013-09-12T01:33:01Z
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)
Comment #1
by safety0ff.bugz — 2014-06-14T20:38:48Z
https://github.com/D-Programming-Language/phobos/pull/2249