title: Array of non-contiguous objects
body: <pre><code>#include &lt;iostream&gt; 
  #include &lt;cstring&gt;
  // This struct is not guaranteed to occupy contiguous storage
  // in the sense of the C++ Object model (§1.8.5):
  struct separated { 
    int i; 
    separated(int a, int b){i=a; i2=b;} 
    ~separated(){i=i2=-1;} // nontrivial destructor --&gt; not trivially   copyable
    private: int i2;       // different access control --&gt; not standard layout
  };
  int main() {
    static_assert(not std::is_standard_layout&lt;separated&gt;::value,"sl");
    static_assert(not std::is_trivial&lt;separated&gt;::value,"tr");
    separated a[2]={{1,2},{3,4}};
    std::memset(&amp;a[0],0,sizeof(a[0]));
    std::cout&lt;&lt;a[1].i;    
    // No guarantee that the previous line outputs 3.
  }
  // compiled with Debian clang version 3.5.0-10, C++14-standard 
  // (outputs 3) 
  </code></pre>
  
  <ol>
  <li><p>What is the rationale behind weakening standard guarantees to the point that this program may show undefined behaviour?</p></li>
  <li><p>The standard says:
  "An object of array type contains a contiguously allocated non-empty set of N subobjects of type T." [dcl.array] §8.3.4.
  If objects of type T do not occupy contiguous storage, how can an array of such objects do?</p></li>
  </ol>
  
  <p>edit: removed possibly distracting explanatory text</p>