On Apr 12, 2011, at 11:18 AM CDT, David Chapman wrote: > On 4/12/2011 8:24 AM, Wan Mohd Fairuz Wan Ismail wrote: >> Hi, >> I did a simple code to test out Overlapping src and dst pointers in memcpy >> using memcheck. But it seems memcheck don't detect the src and dst addresses >> are identical. Any idea? >> >> CODE: >> char* arr = malloc(10); >> memcpy(arr, arr, 10); >> free(arr); > > This is correct; memcpy() does not perform this check. Look at the man page > for it and memmove().
I think the OP's point was that while memcpy may not make this check, the Valgrind tool "memcheck" should catch this usage and report a warning for it, a point that I agree with. It's not especially different in my mind from passing undefined values into a system call (which memcheck does catch), since the behavior in both cases is undefined and likely to cause a problem in your code on at least some platforms. -Dave ------------------------------------------------------------------------------ Forrester Wave Report - Recovery time is now measured in hours and minutes not days. Key insights are discussed in the 2010 Forrester Wave Report as part of an in-depth evaluation of disaster recovery service providers. Forrester found the best-in-class provider in terms of services and vision. Read this report now! http://p.sf.net/sfu/ibm-webcastpromo _______________________________________________ Valgrind-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/valgrind-users
