On Thu, Oct 13, 2011 at 02:57:56PM +0200, Michael Matz wrote: > struct S {int * restrict p;}; > void foo (struct S *s, struct S *t) { > s->p[0] = 0; > t->p[0] = 1; // undefined if s->p == t->p; the caller was responsible > // to not do that
This is undefined only if s->p == t->p && &s->p != &t->p. If both s->p and t->p designate the same restricted pointer object, it is fine. It is just fine to call the above with: struct S u; u.p = p; foo (&u, &u); but not with: struct S u, v; u.p = p; v.p = p; foo (&u, &v); If you change it to void foo (struct S *restrict s, struct S *restrict t) then obviously even calling it with foo (&u, &u) is invalid. Jakub