struct A { mixin(bitfields!(byte, "x", 32)); } unittest { A a; a.x = 17; } produces test.d-mixin-5(6): [unittest] Value is greater than the maximum value of bitfield 'x' The reason is, that a byte cannot hold 32 bits.
@berni44 updated dlang/phobos pull request #7793 "Fix issues 21635 and 21636 - check parameters of bitfields" fixing this issue: - Fix issues 21635, 21636: std.bitmanip: bitfields should produce better error messages with wrong parameters std.bitmanip: bitfields size of bitfield should be checked against size of used type https://github.com/dlang/phobos/pull/7793
dlang/phobos pull request #7793 "Fix issues 21635 and 21636 - check parameters of bitfields" was merged into master: - 50b89cdcacd3ffd36ee2cf7f17d7cb9c611ee939 by berni44: Fix issues 21635, 21636: std.bitmanip: bitfields should produce better error messages with wrong parameters std.bitmanip: bitfields size of bitfield should be checked against size of used type https://github.com/dlang/phobos/pull/7793