[Issue 24624] New: Struct with both bitfields and a slice or class instance ref doesn't compile.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Jun 22 18:03:34 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24624
Issue ID: 24624
Summary: Struct with both bitfields and a slice or class
instance ref doesn't compile.
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: jonas.meeuws at gmail.com
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;
}
---
--
More information about the Digitalmars-d-bugs
mailing list