http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49367
--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> 2011-06-13 18:11:04 UTC --- (In reply to comment #1) > As a1 and a2 are not restrict qualified they may point to the same object > and thus the "two" restrict pointers are based on each other. Marking them with restrict doesn't help: typedef struct A { int *__restrict p; } A; void g(); void f (A*__restrict a1, A*__restrict a2) { *a1->p = 0; *a2->p = 1; if (*a1->p != 0) g(); } int main() { A a,b; f (&a,&b); } Saving the inside pointers into __restrict-qualified temporaries doesn't make it work, either: typedef struct A { int *__restrict p; } A; void g(); void f (A* a1, A* a2) { if (a1 == a2) return; int *__restrict a1p = a1->p; int *__restrict a2p = a2->p; *a1p = 0; *a2p = 1; if (*a1p != 0) g(); } int main() { A a,b; f (&a,&b); } But at this point, if I remove the __restrict from the declaration of p, it works. typedef struct A { int * p; } A; void g(); void f (A* a1, A* a2) { if (a1 == a2) return; int *__restrict a1p = a1->p; int *__restrict a2p = a2->p; *a1p = 0; *a2p = 1; if (*a1p != 0) g(); } int main() { A a,b; f (&a,&b); } It seems rather odd that the __restrict on p would prevent the optimization...