Struct alignment
Johan Engelen
j at j.nl
Sun Sep 24 21:01:06 UTC 2017
DMD <= 2.074 and DMD >= 2.075 disagree on struct alignment.
```
struct UInt {
align(1):
uint a;
}
struct Bug {
ubyte one;
UInt two;
}
static assert(Bug.two.offsetof == 4); // Error DMD>=2.075, 1 == 4
is false
static assert(Bug.sizeof == 8); // Error DMD>=2.075, 5 == 8 is
false
align(1)
struct Align1UInt {
align(1):
uint a;
}
struct BugAlign1 {
ubyte one;
Align1UInt two;
}
static assert(BugAlign1.two.offsetof == 1);
static assert(BugAlign1.sizeof == 5); // Error DMD<=2.074, 8 == 5
is false
```
So... what's correct? :-)
Cheers,
Johan
More information about the Digitalmars-d
mailing list