title: Base pointer to array of derived objects
body: <p>Following a <a href="https://stackoverflow.com/questions/7196172/interview-question-couldnt-answer-it-today">question</a> asked here earlier today and multitudes of similary themed questions, I'm here to ask about this problem from stadard's viewpoint.</p>
  
  <pre><code>struct Base
  {
    int member;
  };
  
  struct Derived : Base
  {
    int another_member;
  };
  
  int main()
  {
    Base* p = new Derived[10]; // (1)
    p[1].member = 42; // (2)
    delete[] p; // (3)
  }
  </code></pre>
  
  <p>According to standard <code>(1)</code> is well-formed, because <code>Dervied*</code> (which is the result of <em>new-expression</em>) can be implicitly converted to <code>Base*</code> (C++11 draft, §4.10/3):</p>
  
  <blockquote>
    <p>A prvalue of type “pointer to <em>cv</em> D”, where D is a class type, can be
    converted to a prvalue of type “pointer to <em>cv</em> B”, where B is a base
    class (Clause 10) of D. If B is an inaccessible (Clause 11) or
    ambiguous (10.2) base class of D, a program that necessitates this
    conversion is ill-formed. The result of the conversion is a pointer to
    the base class subobject of the derived class object. The null pointer
    value is converted to the null pointer value of the destination type.</p>
  </blockquote>
  
  <p><code>(3)</code> leads to undefined behaviour because of §5.3.5/3:</p>
  
  <blockquote>
    <p>In the first alternative (<em>delete object</em>), if the static type of the
    object to be deleted is different from its dynamic type, the static
    type shall be a base class of the dynamic type of the object to be
    deleted and the static type shall have a virtual destructor or the
    behavior is undefined. In the second alternative (<em>delete array</em>) if the
    dynamic type of the object to be deleted differs from its static type,
    the behavior is undefined.</p>
  </blockquote>
  
  <p>Is <code>(2)</code> legal according to standard or does it lead to ill-formed program or undefined behaviour?</p>
  
  <p><em>edit: Better wording</em></p>