Question: The following problem illustrates the way memory aliasing can cause unexpected program behavior. Consider the following procedure to swap two values: 1 2 3 4
The following problem illustrates the way memory aliasing can cause unexpected program behavior. Consider the following procedure to swap two values:

1 2 3 4 5 67 /* Swap value x at xp with value y at yp */ void swap (long *xp, long *yp) { *xp = *xp + *yp; /* x+y *yp *xp *xp = *xp = - */ *yp: /* x+y-y = x */ *yp; /* x+y-x = y */ } If this procedure is called with xp equal to yp, what effect will it have?
Step by Step Solution
3.36 Rating (146 Votes )
There are 3 Steps involved in it
This problem illustrates some of the subtle effects of memory aliasing As the following commented ... View full answer
Get step-by-step solutions from verified subject matter experts
