]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add note about justified pedantry of overlap checking.
authorNicholas Nethercote <njn@valgrind.org>
Tue, 19 Jul 2005 00:48:55 +0000 (00:48 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Tue, 19 Jul 2005 00:48:55 +0000 (00:48 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4174

memcheck/docs/mc-manual.xml

index fa4d490b7db4d63257c917ce5e32cddb324d3773..ae42460a5d41291a8dc665f92f7132dc18c71b75 100644 (file)
@@ -497,6 +497,19 @@ overlap.  Memcheck checks for this.</para>
 <para>You don't want the two blocks to overlap because one of
 them could get partially trashed by the copying.</para>
 
+<para>You might think that Memcheck is being overly pedantic reporting
+this in the case where <computeroutput>dst</computeroutput> is less
+than <computeroutput>src</computeroutput>.  For example, the obvious way
+to implement <computeroutput>memcpy()</computeroutput> is by copying
+from the first byte to the last.  However, the optimisation guides of
+some architectures recommend copying from the last byte down to the first.
+Also, some implementations of <computeroutput>memcpy()</computeroutput>
+zero <computeroutput>dst</computeroutput> before copying, because zeroing
+the destination's cache line(s) can improve performance.</para>
+
+<para>The moral of the story is:  if you want to write truly portable code,
+don't make any assumptions about the language implementation.</para>
+
 </sect2>