title: return value of memcmp(ptr1, ptr2, 0)?
body: <p>In reading: <a href="https://stackoverflow.com/questions/19033521/how-can-i-check-that-elements-of-an-array-are-all-same-without-using-counter">How can I check that elements of an array are all same without using counter?</a> , @Skizz uses the nifty solution:</p>
  
  <pre><code>memcmp (&amp;string [0], &amp;string [1], sizeof string [0] * (N - 1))
  </code></pre>
  
  <p>So if N happens to be 1, we get </p>
  
  <pre><code>memcmp (&amp;string [0], &amp;string [1], 0)
  </code></pre>
  
  <p><strong>Is the return value certain to be 0 when the compare length is 0?</strong></p>
  
  <hr>
  
  <p>Test case (Cygwin gcc version 4.8.1 windows 64-bit) returns <code>0</code>.  So I know on this and a few other compilers/platforms that it is 0.</p>
  
  <pre><code>printf("%d\n", memcmp("foo", "bar", 0));
  </code></pre>
  
  <p>C11 draft spec follows, but appears quiet on the issue.  Maybe another part of the spec or something says something?</p>
  
  <p>7.24.4.1 The memcmp function<br>
  Synopsis  </p>
  
  <pre><code>#include &lt;string.h&gt;
  int memcmp(const void *s1, const void *s2, size_t n);
  </code></pre>
  
  <p>Description<br>
  The memcmp function compares the first n characters of the object pointed to by s1 to
  the first n characters of the object pointed to by s2.  </p>
  
  <p>Returns<br>
  The memcmp function returns an integer greater than, equal to, or less than zero,
  accordingly as the object pointed to by s1 is greater than, equal to, or less than the object
  pointed to by s2.</p>
  
  <hr>
  
  <p>(Assume &amp;string [1] did not reference illegal memory)</p>