title: When is it safe to call this-> in constructor and destructor
body: <p>I've not been able to find a conclusive answer to this so far. When is it safe to call <code>this-&gt;</code> from within an object. And in particular from inside the constructor and destructor.</p>
  
  <p>And also, when using public inheritance. Is it safe to use up and downcasting on the result of the this call?</p>
  
  <p>So for example:</p>
  
  <pre><code>class foo
  {
     foo():
     a(),
     b(this-&gt;a)//case 1
     {
         this-&gt; a = 5; //case 2
     }
  
     int a;
     int b;
  };
  
  class bar: public baz
  {
     bar():
     baz(this)//case 3 - assuming baz has a valid constructor
     {
  
  
     }
  
  }
  </code></pre>
  
  <p>And finally the most unlikely one</p>
  
  <pre><code>foo()
     {
        if(static_cast&lt;bar*&gt;(this));//case 4
     }
  </code></pre>
  
  <p>Which of the above cases are legal?</p>
  
  <p><strong>Note:</strong> I'm aware a lot of the practices above are inadvisable. </p>