4 ms·
Looking at the man page for memcpy, it states that it is explicitly for non-overlapping memory areas. Depending on implementation, then, it might even be "corre
by likpok 17y ago
Looking at the man page for memcpy, it states that it is explicitly for non-overlapping memory areas. Depending on implementation, then, it might even be "correct" behavior to leave the array in an inconsistent state (if the results are not well-defined).
- mooism2 17y agoThey are non-overlapping memory areas: "Note that in our case the source and destination memcpy() regions are completely disjoint." (2nd para) And the array is not left in an inconsistent state. They are doing the equivalent of memcpy (a, b, n); memcpy (b, a, n); and a different thread running at the same time observes incorrect data in the supposedly unaltered `b[]` during the second memcpy.