Bug 18134 – BitArray >>= broken when length % (8 * size_t.sizeof) == 0

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-12-27T21:34:21Z
Last change time
2018-03-06T19:14:11Z
Assigned to
Jakub Łabaj
Creator
Simen Kjaeraas

Comments

Comment #0 by simen.kjaras — 2017-12-27T21:34:21Z
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.
Comment #1 by petar.p.kirov — 2017-12-29T10:25:33Z
Comment #2 by uaaabbjjkl — 2018-02-02T14:26:44Z
Seems like it was wrong only for multiples of size_t.sizeof. I made a PR fixing this: https://github.com/dlang/phobos/pull/6110.
Comment #3 by github-bugzilla — 2018-03-06T19:14:09Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/b211347454b70fdb5a539f3fd8bc82fcec846e70 Fix issue 18134 - BitArray right shift broken if length is multiple of 8*size_t.sizeof https://github.com/dlang/phobos/commit/6264e40d8abbb411d4391b3cf8c4d2d4c69423e1 Merge pull request #6110 from byebye/issue_18134 Fix issue 18134 - BitArray right shift broken if length is multiple of 8*size_t.sizeof merged-on-behalf-of: Jack Stouffer <[email protected]>