Bug 21636 – std.bitmanip: bitfields size of bitfield should be checked against size of used type

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-02-13T10:46:09Z
Last change time
2021-02-16T13:02:11Z
Keywords
pull
Assigned to
No Owner
Creator
Berni44

Comments

Comment #0 by bugzilla — 2021-02-13T10:46:09Z
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.
Comment #1 by dlang-bot — 2021-02-16T09:14:43Z
@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
Comment #2 by dlang-bot — 2021-02-16T13:02:11Z
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