title: Unexpected behaviour with constructors
body: <p>Simple program:</p>
  
  <pre><code>#include &lt;iostream&gt; 
  
  using namespace::std;
  
  
  class X {
      public:
          X() {
              cout &lt;&lt; "Default Constructor called\n";
              i = 0;
          }
  
  
          X(int i) {
              cout &lt;&lt; "Parameterized Constructor called\n";
              this-&gt;i = i;
          }
          X(const X&amp; x) {
              cout &lt;&lt; "Copy Constructor called\n";
              i = x.getI();
          }
          ~X() {
              cout &lt;&lt; "Destructor called\n";
          }
          int getI() const {
              return i;
          }
          X func() {
              cout &lt;&lt; "Entered func\n";
              X x(2);
              return x;
          }
      private:
          int i;
  };
  
  int main() {
       X x1;
       X x2 = x1.func();
      cout &lt;&lt; "Returned from func\n";    
  }
  </code></pre>
  
  <p>It outputs the following:</p>
  
  <pre><code>Default Constructor called
  Entered func
  Parameterized Constructor called
  Copy Constructor called
  Destructor called
  Returned from func
  Destructor called
  Destructor called
  </code></pre>
  
  <p><strong>My issue is that after the 'Returned from func' is printed, no constructor is called when creating the instance x2. I was actually expecting a copy constructor to be called when instantiating x2 as it would have been if we did something like <code>X x2 = x1;</code></strong></p>