title: Why is this code trying to call the copy constructor?
body: <p>I just spent an inordinate amount of time fiddling with a complilation error in Visual Studio. I have distilled the code into the small compilable example below and tried it on IdeOne and got the same error which you can see <a href="http://ideone.com/G3HYu" rel="noreferrer">here</a>.</p>
  
  <p>I am wondering why the following code tries to call <code>B(const B&amp;)</code> instead of <code>B(B&amp;&amp;)</code>:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  class A {
  public:
      A() : data(53) { }
      A(A&amp;&amp; dying) : data(dying.data) { dying.data = 0; }
  
      int data;
  
  private:
      // not implemented, this is a noncopyable class
      A(const A&amp;);
      A&amp; operator=(const A&amp;);
  };
  
  class B : public A { };
  
  int main() {
      B binst;
  
      char* buf = new char[sizeof(B)];
  
      B* bptr = new (buf) B(std::move(binst));
  
      cout &lt;&lt; bptr-&gt;data &lt;&lt; endl;
  
      delete[] buf;
  }
  </code></pre>
  
  <p>I didn't explicitly define any constructors, so <code>B(std::move(binst))</code> should call the compiler generated <code>B(B&amp;&amp;)</code>, no?</p>
  
  <p>When I change <code>B</code> to</p>
  
  <pre><code>class B : public A {
  public:
      B() { }
      B(B&amp;&amp;) { }
  };
  </code></pre>
  
  <p>It compiles fine. Why is this?</p>
  
  <p>It will be extremely inconvenient if this can't be fixed from the base class because I have a template class which uses placement new and move constructors like the example, and it will require every class that is not copyable (which is not and definitely should not be a requirement for use with my template class) to have an explicitly defined move constructor.</p>