title: Why is the copy-constructor not called when returning by-value a list-initialized object?
body: <p>I understand that when objects are returned by-value from a function, their copy-constructors are called. If a class has a deleted copy-constructor, returning by value will fail.</p>
  
  <pre><code>struct X {
      X(const X &amp;) = delete;
  };
  
  X f() {
     return X{};
  }
  </code></pre>
  
  <blockquote>
    <p><code>error: call to deleted constructor of 'X'</code></p>
  </blockquote>
  
  <p>C++11 gives us extended-initializers. And I read somewhere on a SO post that this</p>
  
  <pre><code>X f() {
      return {};
  }
  </code></pre>
  
  <p>is the same as</p>
  
  <pre><code>X f() {
      return X{};
  }
  </code></pre>
  
  <p>So why doesn't the below code give me an error? It passes and I even get to call the function in main:</p>
  
  <pre><code>struct D {
     D(const D &amp;) = delete;
  };
  
  D f() { return {}; }
  
  int main()
  {
     f();
  }
  </code></pre>
  
  <p><a href="http://liveworkspace.org/code/4yc7Hy$2171" rel="noreferrer">Here is a demo.</a> No error is reported. I find that weird because I believe that the copy-constructor should be called. Can anyone explain why no error is given?</p>