Is it well-defined to use a pointer pointing to one-past-malloc?
问题 In C, it is perfectly well to make a pointer that points to one past the last element of an array and use it in pointer arithmetics, as long as you don't dereference it: int a[5], *p = a+5, diff = p-a; // Well-defined However, these are UBs: p = a+6; int b = *(a+5), diff = p-a; // Dereferencing and pointer arithmetic Now I have a question: Does this apply to dynamically allocated memory? Assume I'm only using a pointer pointing to one-past-the-last in pointer arithmetics, without