after reading about sequence points, I learned that i = ++i is undefined.
i = ++i
So how about this code:
int i; int *p = &i; int *q = &i;
The best tool not to detect, but to avoid this in the first place is to use good programming practice. Avoid side-effects and do no more than one write per assignment. There is nothing wrong with
*q += 1; *p = *q;