title: T* versus char* pointer arithmetic
body: <p>Assume we have an array that contains N elements of type T.</p>
  
  <pre><code>T a[N];
  </code></pre>
  
  <p><em>According to the C++14 Standard</em>, under which conditions do we have a guarantee that</p>
  
  <pre><code> (char*)(void*)&amp;a[0] + n*sizeof(T) == (char*)(void*)&amp;a[n],  (0&lt;=n&lt;N) ?
  </code></pre>
  
  <p>While this is true for many types and implementations, the standard mentions it in a footnote, and in an ambiguous way:</p>
  
  <blockquote>
    <p>§5.7.6, footnote 85) Another way to approach pointer arithmetic ...</p>
  </blockquote>
  
  <p>There is little indication that this other way was thought of being equivalent to the standard's way. It might rather be a hint for implementers that suggests one of many conforming implementations.</p>
  
  <hr>
  
  <p>Edits:</p>
  
  <p>People have underestimated the difficulty of this question.</p>
  
  <p>This question is not about what you can read in textbooks, it is about what what you can deduce from the C++14 Standard through the use of logic and reason.</p>
  
  <p>If you use 'contiguous' or 'contiguously', please also say what is being contiguous.</p>
  
  <p>While T[] and T* are closely related, they are abstractions, and the addition on T* x N may be defined by the implementation in any consistent way.</p>
  
  <p>The equation was rearranged using pointer addition. If p points to a char, p+1 is always defined using (§5.7 (4)) or unary addition, so we don't run into UB. The original included a pointer subtraction, which might have caused UB early on. (The char pointers are only compared, not dereferenced).</p>