struct S {
ubyte _x:4, _y:4;
ubyte* p() => &_x; // Error: cannot take address of bit-field `_x`
ref ubyte x() => _x; // Compiles
}
Comment #1 by nick — 2024-03-09T14:44:41Z
Same when passing a bitfield as a ref argument:
struct S
{
uint a:1,
b:1,
c:1;
}
void f(ref uint b) { b++; }
void main()
{
S s;
s.a.f; // allowed! Silently does nothing
assert(s.a == 0); // unaffected
}
Comment #2 by robert.schadek — 2024-12-13T19:32:01Z