agg_nested.c (579B)
1 /* A NESTED struct: an inner struct embedded in an outer one, accessed via 2 * chained member offsets (outer.inner.field). Exercises nested field offset 3 * computation in loads/stores. Passed by pointer to keep the access pattern 4 * about offset math. Result: 10 + 12 + 20 = 42. */ 5 struct Inner { 6 int x; 7 int y; 8 }; 9 struct Outer { 10 int tag; 11 struct Inner in; 12 }; 13 __attribute__((noinline)) static int eval(struct Outer* o) { 14 return o->tag + o->in.x + o->in.y; 15 } 16 int test_main(void) { 17 volatile int a = 10, b = 12, c = 20; 18 struct Outer o = {a, {b, c}}; 19 return eval(&o); 20 }