93 expecti(g.a[0], 1024);
94 expecti(g.b[1], 2048);
95 expecti(g.a[4], 2048); // &g.a[4] == &g.b[0]
106 expecti((*h).a, 128);
111 expecti((*h).a, 256);
121 expecti(i[1].b, 128);
123 expecti(j[3], 128); // &j[3] == &i[1].b
125 struct { char c; } k = { 'a' };
128 struct { int a[3]; } l = { { 1, 2, 3 } };
150 // structure copy via assignment
176 struct cell aa = { 10, 0 };
177 struct cell bb = { 20, &aa };
178 struct cell cc = { 30, &bb };
179 struct cell *dd = &cc;
181 expecti(cc.value, 30);
182 expecti(dd->value, 30);
183 expecti(dd->next->value, 20);
184 expecti(dd->next->next->value, 10);
187 dd->next->value = 32;
188 dd->next->next->value = 64;
189 expecti(dd->value, 16);
190 expecti(dd->next->value, 32);
191 expecti(dd->next->next->value, 64);
199 } poke = { 99, 100 };
201 int *poke1 = &poke.a;
202 int *poke2 = &poke.y.b;
205 expecti(*poke2, 100);
206 expecti(*&poke.a, 99);
207 expecti(*&poke.y.b, 100);
209 struct super *inward = &poke;
210 int *poke3 = &inward->a;
211 int *poke4 = &inward->y.b;
214 expecti(*poke4, 100);
215 expecti(*&inward->a, 99);
216 expecti(*&inward->y.b, 100);
218 // incomplete in the opposite direction
221 struct incomplete1 *next;
227 struct incomplete1 in1 = { 3 };
228 struct incomplete2 in2 = { &in1 };
230 expecti(in2.next->value, 3);
253 expecti(bitfield.i, 500); // (15 << 5) + 20 == 500
258 } bitfield2 = { 5, 10 };
260 expecti(bitfield2.a, 5);
261 expecti(bitfield2.b, 10);
270 expecti(bitfield3.a, 2);
271 expecti(bitfield3.b, 2);
272 expecti(bitfield3.c, 2);
275 expecti(sizeof(struct __empty), 0);
278 struct __fam0 { int a, b[]; };
279 struct __fam1 { int a, b[0]; };
281 expecti(sizeof(struct __fam0), 4);
282 expecti(sizeof(struct __fam1), 4);
284 struct __gccfam { int a[0]; };
285 expecti(sizeof(struct __gccfam), 0);
287 struct __famoverwrite { int a, b[]; };
288 struct __famoverwrite OV = { 1, 2, 3, 4, 5 };