title: Downcasting non-polymorphic types?
body: <p>Please consider the following C++20 program:</p>
  <pre><code>struct B { B(); private: int whatever; }; // non-aggregate
  struct D : B { D(); int x; private: int whatever2; }; // non-aggregate
  
  int main() {
     D* d = new D;
     d-&gt;x = 42;
     B* b = (B*) d;
     D* d2 = (D*) b;
     return d2-&gt;x;
  }
  </code></pre>
  <p>Is this program ill-formed or have undefined behaviour?</p>
  <p>That is, is it allowed to cast a pointer to the base subobject of a derived object of non-polymorphic type to a pointer to the derived object itself?</p>
  <p>If so, would one of the <code>*_cast&lt;T&gt;</code> functions be more appropriate than the C-style cast?</p>
  <p>(Also, if the pointer is to a <code>B</code> object that isn't a base subobject of an object of type <code>D</code>, then its undefined behaviour, right?  The implementation has no way to check if the cast is correct, as it does with a <code>dynamic_cast</code> ?)</p>