title: C/C++ Struct memory layout equivalency
body: <p>Consider the following C struct and C++ struct declarations:</p>
  
  <pre><code>extern "C" { // if this matters
  typedef struct Rect1 {
    int x, y;
    int w, h;
  } Rect1;
  }
  
  struct Vector {
    int x;
    int y;
  }
  
  struct Rect2 {
    Vector pos;
    Vector size;
  }
  </code></pre>
  
  <ul>
  <li><p>Are the memory layouts of <code>Rect1</code> and <code>Rect2</code> objects always identical?</p></li>
  <li><p>Specifically, can I safely <code>reinterpret_cast</code> from <code>Rect2*</code> to <code>Rect1*</code> and assume that all four <code>int</code> values in the <code>Rect2</code> object are matched one on one to the four <code>int</code>s in <code>Rect1</code>?</p></li>
  <li><p>Does it make a difference if I change <code>Rect2</code> to a non-POD type, e.g. by adding a constructor?</p></li>
  </ul>