title: Does an external pointer reference to a field of a deleted struct makes the pointer refers to garbage values in C++?
body: <p>I have a fundamental doubt regarding struct deallocation and pointer usage in C++.</p>
  
  <p>Suppose I have the following scenario:</p>
  
  <pre><code>...
  struct B
  {
      ...
      struct A a_field;
      ...
  }
  ...
  struct A* a_ref;
  vector&lt;struct B&gt; b_vec;
  ...
  // populate, use and modify b_vec elements here
  ...
  a_ref = &amp;(b_vec[i].a_field); // can be a one-time assignment
  ...
  // deallocate b_vec elements here (including b_vec[i]) here
  ...
  // using a_ref-&gt;some_field here !?!
  ...
  </code></pre>
  
  <p>Is <code>a_ref</code> still going to point to the last modified state of the <code>a_field</code> of <code>b_vec[i]</code>, making it reliable for use later?</p>
  
  <p>Or is C++-STL deallocation going to make all the fields of <code>b_vec[i]</code> unreliable (garbage value) when it pushes it out of the vector?</p>