title: why constructors "return" this pointer?
body: <p>I noticed that the constructor will move <code>this</code> to <code>eax</code> before returning. This is a return value or something else?</p>
  
  <pre><code>class CTest {
      int val_;
  public:
      CTest() {
  0093F700  push        ebp  
  0093F701  mov         ebp,esp  
  0093F703  sub         esp,0CCh  
  0093F709  push        ebx  
  0093F70A  push        esi  
  0093F70B  push        edi  
  0093F70C  push        ecx  
  0093F70D  lea         edi,[ebp-0CCh]  
  0093F713  mov         ecx,33h  
  0093F718  mov         eax,0CCCCCCCCh  
  0093F71D  rep stos    dword ptr es:[edi]  
  0093F71F  pop         ecx  
  0093F720  mov         dword ptr [this],ecx  
          val_ = 1;
  0093F723  mov         eax,dword ptr [this]  
  0093F726  mov         dword ptr [eax],1  
      }
  0093F72C  mov         eax,dword ptr [this]  
  0093F72F  pop         edi  
  0093F730  pop         esi  
  0093F731  pop         ebx  
  0093F732  mov         esp,ebp  
  0093F734  pop         ebp  
  0093F735  ret  
  </code></pre>
  
  <p>VS2012 debug mode</p>
  
  <hr>
  
  <p>I found that <code>new</code> will use its "return value". Seems like <code>if(operator new() == 0) return 0; else return constructor();</code></p>
  
  <pre><code>class CTest {
      int val_;
  public:
      CTest() {
          val_ = 1;
          __asm {
              mov         eax, 0x12345678
              pop         edi  
              pop         esi  
              pop         ebx  
              mov         esp,ebp  
              pop         ebp  
              ret  
          }
      }
  };
  
  int main() {
      CTest *test = new CTest;    // test == 0x12345678
      return 0;
  }
  </code></pre>