* Andrew Makhorin: >> No, that is not how it works. 6.2.4/2 says: [...] "The value of a >> pointer becomes indeterminate when the object it points to (or just >> past) reaches the end of its lifetime." >> >> It does not matter whether the value of p changes in *your* system, >> or in most systems. Using the value of p after deallocating the object >> it pointed to is undefined behaviour. >> > > Does this mean that the following fragment is invalid? (I think it > isn't.) > > void *p, *q; > p = malloc(123); > q = p; > free(p); > if (p == q) ... Another common problem is the use of realloc with internal pointers, adjusting them after the object has been moved. There's no clean way to write such code, except to avoid using pointers and use uintptr_t everywhere.