Bug 24624 – Struct with both bitfields and a slice or class instance ref doesn't compile.

Status
NEW
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2024-06-22T18:03:34Z
Last change time
2024-12-13T19:35:56Z
Assigned to
No Owner
Creator
Jonas Meeuws
Moved to GitHub: dmd#20473 →

Comments

Comment #0 by jonas.meeuws — 2024-06-22T18:03:34Z
Compiling the following code with -preview=bitfields: --- struct S { char[] slice; bool flag:1; } --- Produces: "Error: cannot take address of bit-field `flag`". After experimenting it seems that: - A struct with bitfields cannot contain: - Slices of any type. - Class instance references. - Structs, enums or references to classes containing any of the above. - Bitfields in classes or named unions are not affected. - When wrapping the bitfields in a named struct, the issue doesn't happen. - With -betterC or ldcs --fno-rtti, the issue doesn't happen. The issue might involve TypeInfo_Struct? More failing examples: --- struct S1 { bool flag:1; Object o; } struct Wrapper2 { void[] wrapped; } struct S2 { bool flag:1; Wrapper2 wrapper; } struct Wrapper3 { Object wrapped; } struct S3 { bool flag:1; Wrapper3 wrapper; } enum Wrapper4 : string { empty = "" } struct S4 { bool flag:1; Wrapper4 wrapper; } ---
Comment #1 by robert.schadek — 2024-12-13T19:35:56Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20473 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB