1 extern void abort (void);
2
3 struct A
4 {
5 struct A *a;
6 };
7
8 struct B
9 {
10 struct A *b;
11 };
12
13 __attribute__((noinline))
14 struct A *
foo(struct A * x)15 foo (struct A *x)
16 {
17 asm volatile ("" : : "g" (x) : "memory");
18 return x;
19 }
20
21 __attribute__((noinline))
22 void
bar(struct B * w,struct A * x,struct A * y,struct A * z)23 bar (struct B *w, struct A *x, struct A *y, struct A *z)
24 {
25 struct A **c;
26 c = &w->b;
27 *c = foo (x);
28 while (*c)
29 c = &(*c)->a;
30 *c = foo (y);
31 while (*c)
32 c = &(*c)->a;
33 *c = foo (z);
34 }
35
36 struct B d;
37 struct A e, f, g;
38
39 int
main(void)40 main (void)
41 {
42 f.a = &g;
43 bar (&d, &e, &f, 0);
44 if (d.b == 0
45 || d.b->a == 0
46 || d.b->a->a == 0
47 || d.b->a->a->a != 0)
48 abort ();
49 return 0;
50 }
51
52