title: Is the behavior of subtracting two NULL pointers defined?
body: <p>Is the difference of two non-void pointer variables defined (per C99 and/or C++98) if they are both <code>NULL</code> valued?</p>
  
  <p>For instance, say I have a buffer structure that looks like this:</p>
  
  <pre><code>struct buf {
    char *buf;
    char *pwrite;
    char *pread;
  } ex;
  </code></pre>
  
  <p>Say, <code>ex.buf</code> points to an array or some malloc'ed memory. If my code always ensures that <code>pwrite</code> and <code>pread</code> point within that array or one past it, then I am fairly confident that <code>ex.pwrite - ex.pread</code> will always be defined. However, what if <code>pwrite</code> and <code>pread</code> are both NULL. Can I just expect subtracting the two is defined as <code>(ptrdiff_t)0</code> or does strictly compliant code need to test the pointers for NULL? Note that the only case I am interested in is when <em>both</em> pointers are NULL (which represents a buffer not initialized case). The reason has to do with a fully compliant "available" function given the preceding assumptions are met:</p>
  
  <pre><code>size_t buf_avail(const struct s_buf *b)
  {     
      return b-&gt;pwrite - b-&gt;pread;
  }
  </code></pre>