www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15305] New: std.manip.bitfields generate bogous code

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

          Issue ID: 15305
           Summary: std.manip.bitfields generate bogous code
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: major
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: deadalnix gmail.com

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.

--
Nov 08 2015