catbutt
asked on
c standards with regard to pointer behavior
If i have two pointers to structures a and b, like this:
Thing *a, *b;
I can copy the contents of the Thing pointed to by b to a like so:
*a = *b;
(which is basically the same as memcpy (a, b, sizeof(*a))...)
So the question is, what if a and b both point to exact same location? Is the behavior undefined, or should it leave the contents unchanged as you would expect?
I can test it easily, but i want to know if it is guaranteed portable.
Thing *a, *b;
I can copy the contents of the Thing pointed to by b to a like so:
*a = *b;
(which is basically the same as memcpy (a, b, sizeof(*a))...)
So the question is, what if a and b both point to exact same location? Is the behavior undefined, or should it leave the contents unchanged as you would expect?
I can test it easily, but i want to know if it is guaranteed portable.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
:o)
ASKER