Bug 24263 – -preview=bitfields: Bit field address escapes through `ref`

Status
NEW
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-11-27T14:24:13Z
Last change time
2024-12-13T19:32:01Z
Keywords
accepts-invalid
Assigned to
No Owner
Creator
Georgy Markov
Moved to GitHub: dmd#20365 →

Comments

Comment #0 by ogion.art — 2023-11-27T14:24:13Z
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
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20365 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB