import std.bitmanip; struct S { mixin(bitfields!( bool, "alice", 1, ulong, "bob", 63, )); } S s; s.bob = long.max - 1; s.alice = false; assert(s.bob == long.max - 1); Setting alice to false is clearing bits in bob, while it really shouldn't.
The generated setter for alice is wrong: @property void alice(bool v) @safe pure nothrow @nogc { if (v) _alice_bob |= 1U;else _alice_bob &= ~1U;} and it's wrong because the &=~1U would clear not just the first bit, but bits 32-64 as well. This in turn because of the code in myToString, which picks the smallest type suffix, "U" in this case.
https://github.com/D-Programming-Language/phobos/pull/3815
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/8e452d8dd484866a6be2c3c180a664ee57b16905 [Issue 15305] bitfields! setter erroneously clears subsequent fields https://github.com/D-Programming-Language/phobos/commit/4e53643652b8e927965c9888c35859c2a81bd56a Merge pull request #3815 from lionello/issue15305 [Issue 15305] bitfields! setter erroneously clears subsequent fields
Commits pushed to stable at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/8e452d8dd484866a6be2c3c180a664ee57b16905 [Issue 15305] bitfields! setter erroneously clears subsequent fields https://github.com/D-Programming-Language/phobos/commit/4e53643652b8e927965c9888c35859c2a81bd56a Merge pull request #3815 from lionello/issue15305