Jerry Feldman wrote:
On Sun, 07 May 2006 14:21:20 +0200 Per Jessen
wrote: valgrind always complains about overlapping strcpy()s, even when the src-address is clearly > dst-address. I know the strcpy manpage says the operands may not overlap, but surely an overlap where src>dst is still ok? Why is valgrind unhappy about it?
It does not matter if src < dst or dst < src. What matters is that dst does not lie anywhere in src, or vice versa.
Can you elaborate on that, in particular why src cannot lie anywhere in dst. If I was programming assembler, that's a perfectly valid MOV.
Many times, in string processing I have had situations like: char *dst = "abcd": char *src = dst + 2; strcpy(dst, src); In this case the result will be "cd". But, there is also an overlap.
That's the situation that valgrind complains about. Using a memmove() instead of strcpy() in this example would seem like overkill? /Per Jessen, Zürich