title: C++11 - I lost a move/copy assignment
body: <p>I posted this code in another question but I have a new doubt on it:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;vector&gt;
  using namespace std;
  
  class X
  {
      public:
  
      std::vector&lt;double&gt; data;
  
      // Constructor1
      X():
          data(100000) // lots of data
      {
          cout &lt;&lt; "X default constructor called";
      }
  
      // Constructor2
      X(X const&amp; other): // copy constructor
          data(other.data)   // duplicate all that data
      {
          cout &lt;&lt; "X copy constructor called";
      }
  
      // Constructor3
      X(X&amp;&amp; other):  // move constructor
          data(std::move(other.data)) // move the data: no copies
      {
          cout &lt;&lt; "X move constructor called";
      }
  
      X&amp; operator=(X const&amp; other) // copy-assignment
      {
          cout &lt;&lt; "X copy assignment called";
          data=other.data; // copy all the data
          return *this;
      }
  
      X&amp; operator=(X &amp;&amp; other) // move-assignment
      {
          cout &lt;&lt; "X move assignment called";
          data=std::move(other.data); // move the data: no copies
          return *this;
      }
  
  };
  
  class X2
  {
      public:
  
      std::vector&lt;double&gt; data;
  
      // Constructor1
      X2():
          data(100000) // lots of data
      {}
  
      // Constructor2
      X2(X const&amp; other): // copy constructor
          data(other.data)   // duplicate all that data
      {}
  
      X2&amp; operator=(X const&amp; other) // copy-assignment
      {
          data=other.data; // copy all the data
          return *this;
      }
  };
  
  X make_x()
  {
      X myNewObject; // Il normale costruttore viene chiamato qui
      myNewObject.data.push_back(22);
      return myNewObject; // Si crea un oggetto temporaneo prima di ritornare con il move constructor perchè myNewObject dev'essere distrutto
  }
  
  
  int main()
  {
      X x1 = make_x(); // x1 has a move constructor
  
  
      X2 x2 = make_x(); // x2 hasn't a move constructor
  }
  </code></pre>
  
  <p>In the main() lines I would expect the move assignment and the copy assignment to get called... but they don't!</p>
  
  <p>MSVC2012 output is:</p>
  
  <blockquote>
    <p>X default constructor called X move constructor called X default
    constructor called X move constructor called</p>
  </blockquote>
  
  <p>And g++'s one is</p>
  
  <blockquote>
    <p>X default constructor called X default constructor called</p>
  </blockquote>
  
  <p><a href="http://liveworkspace.org/code/220erd" rel="nofollow">http://liveworkspace.org/code/220erd</a>$2</p>
  
  <p>Where are the assignments?? I thought the first main() line would call a move assignment and the second main() line would call a copy assignment</p>