karl@haddock.ima.isc.com (Karl Heuer) (09/14/88)
In article <2063@cuuxb.ATT.COM> mmengel@cuuxb.ATT.COM (Marc Mengel) writes: >To check whether the source and destination overlap, you have to compare two >pointer values. You can only do this legally ($3.3.8) if the two pointers >point into the same array/aggregate. Watch it -- the first `you' refers to the implementation; the second refers to the user. Certainly the implementation is free to generate any code that happens to work. >Hence you need memmove() for shifting items in an array, and memcpy() for >moving items between arrays. Using memmove() on items not in the same array >is therefore not guaranteed to work, as the comparison of pointers not in the >same array/aggregate is undefined. No, memmove() is guaranteed to work on *any* valid pointers. What you've really proved is that memmove() cannot be portably implemented in C. Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint Followups to comp.std.c.