title: Why g++ does not enable RVO here?
body: <p>Consider that TEST code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  class Klass
  {
  public:
    Klass()
    {
      cout &lt;&lt; "Klass()" &lt;&lt; endl;
    }
  
    Klass(const Klass&amp; right)
    {
      cout &lt;&lt; "Klass(const Klass&amp; right)" &lt;&lt; endl;
    }
  };
  
  Klass create(Klass a)
  {
    cout &lt;&lt; "create(Klass a)" &lt;&lt; endl;
    return a;
  }
  
  int main()
  {
    const Klass result = create(Klass());
  }
  </code></pre>
  
  <p>Compiling with: </p>
  
  <pre><code>g++ -O3 rvo.cpp   -o rvo
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>$ ./rvo
  Klass()
  create(Klass a)
  Klass(const Klass&amp; right)
  </code></pre>
  
  <p><strong>I was expecting the compiler to use the RVO mechanism in order elide every COPY CTOR call, to avoid copying the return value AND the parameter of the function <code>create()</code>. Why isn't it the case?</strong></p>