If I have something like this in my code:
void f(struct foo *x, struct foo *y)
{
*x = *y; // structure copy (memcpy?)
}
If x and y point to the same address, what happens?
Is this valid code, and what if the compiler converts the assignment into a memcpy call with potentially-invalid operands (they aren't allowed to overlap)?
[Yes, I know I can use "restrict" in this case, but the actual code we found which made us consider this is automatically-generated by bison so we were wondering if it should always be valid and whether the compiler should use memmove or something else which allows overlap..]