title: Is adding to a "char *" pointer UB, when it doesn't actually point to a char array?
body: <p>C++17 (<a href="http://eel.is/c++draft/expr.add#4" rel="noreferrer">expr.add/4</a>) say:</p>
  
  <blockquote>
    <p>When an expression that has integral type is added to or subtracted
    from a pointer, the result has the type of the pointer operand. If the
    expression P points to element x[i] of an array object x with n
    elements, the expressions P + J and J + P (where J has the value j)
    point to the (possibly-hypothetical) element x[i+j] if 0≤i+j≤n;
    otherwise, the behavior is undefined. Likewise, the expression P - J
    points to the (possibly-hypothetical) element x[i−j] if 0≤i−j≤n;
    otherwise, the behavior is undefined.</p>
  </blockquote>
  
  <pre><code>struct Foo {
      float x, y, z;
  };
  
  Foo f;
  char *p = reinterpret_cast&lt;char*&gt;(&amp;f) + offsetof(Foo, z); // (*)
  *reinterpret_cast&lt;float*&gt;(p) = 42.0f;
  </code></pre>
  
  <p>Has the line marked with (*) UB? <code>reinterpret_cast&lt;char*&gt;(&amp;f)</code> doesn't point to a char array, but to a float, so it should UB according to the cited paragraph. But, if it is UB, then <code>offsetof</code>'s usefulness would be limited.</p>
  
  <p>Is it UB? If not, why not?</p>