www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21636] New: std.bitmanip: bitfields size of bitfield should

https://issues.dlang.org/show_bug.cgi?id=21636

          Issue ID: 21636
           Summary: std.bitmanip: bitfields size of bitfield should be
                    checked against size of used type
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: bugzilla bernis-buecher.de

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.

--
Feb 13