| 1 |
// PERMUTE_ARGS: |
| 2 |
|
| 3 |
size_t getAlign9766(size_t n) { return n; } |
| 4 |
|
| 5 |
struct S9766 |
| 6 |
{ |
| 7 |
align(getAlign9766(1)): |
| 8 |
ubyte[5] pad1; |
| 9 |
ubyte var1; |
| 10 |
|
| 11 |
align(getAlign9766(2)): |
| 12 |
ubyte[5] pad2; |
| 13 |
ubyte var2; |
| 14 |
|
| 15 |
align(getAlign9766(4)): |
| 16 |
ubyte[5] pad3; |
| 17 |
ubyte var3; |
| 18 |
|
| 19 |
align(getAlign9766(8)): |
| 20 |
ubyte[5] pad4; |
| 21 |
ubyte var4; |
| 22 |
} |
| 23 |
|
| 24 |
static assert(S9766.pad1.offsetof == 0); |
| 25 |
static assert(S9766.var1.offsetof == 5); |
| 26 |
|
| 27 |
static assert(S9766.pad2.offsetof == 6); |
| 28 |
static assert(S9766.var2.offsetof == 12); |
| 29 |
|
| 30 |
static assert(S9766.pad3.offsetof == 16); |
| 31 |
static assert(S9766.var3.offsetof == 24); |
| 32 |
|
| 33 |
static assert(S9766.pad4.offsetof == 32); |
| 34 |
static assert(S9766.var4.offsetof == 40); |
| 35 |
|
| 36 |
union U9766 |
| 37 |
{ |
| 38 |
struct |
| 39 |
{ |
| 40 |
align(getAlign9766(1)): |
| 41 |
ubyte[5] pad1; |
| 42 |
ubyte var1; |
| 43 |
|
| 44 |
align(getAlign9766(2)): |
| 45 |
ubyte[5] pad2; |
| 46 |
ubyte var2; |
| 47 |
|
| 48 |
align(getAlign9766(4)): |
| 49 |
ubyte[5] pad3; |
| 50 |
ubyte var3; |
| 51 |
|
| 52 |
align(getAlign9766(8)): |
| 53 |
ubyte[5] pad4; |
| 54 |
ubyte var4; |
| 55 |
} |
| 56 |
} |
| 57 |
|
| 58 |
static assert(U9766.pad1.offsetof == 0); |
| 59 |
static assert(U9766.var1.offsetof == 5); |
| 60 |
|
| 61 |
static assert(U9766.pad2.offsetof == 6); |
| 62 |
static assert(U9766.var2.offsetof == 12); |
| 63 |
|
| 64 |
static assert(U9766.pad3.offsetof == 16); |
| 65 |
static assert(U9766.var3.offsetof == 24); |
| 66 |
|
| 67 |
static assert(U9766.pad4.offsetof == 32); |
| 68 |
static assert(U9766.var4.offsetof == 40); |
| 69 |
|
| 70 |
struct TestMaxAlign |
| 71 |
{ |
| 72 |
align(1u << 15): |
| 73 |
ubyte a; |
| 74 |
ubyte b; |
| 75 |
} |
| 76 |
|
| 77 |
static assert(TestMaxAlign.b.offsetof == (1 << 15)); |