title: When should RVO kick-in?
body: <p>From the following code, If RVO has happened, I expect to see the 2 addresses pointing to the same location, however this is not the case (my compiler is MS VC9.0)</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  std::string foo(std::string&amp; s)
  {
     std::cout &lt;&lt; "address: " &lt;&lt; (unsigned int)(&amp;s) &lt;&lt; std::endl;
     return s;
  }
  
  int main()
  {
     std::string base = "abc";
     const std::string&amp; s = foo(base);
     std::cout &lt;&lt; "address: " &lt;&lt; (unsigned int)(&amp;s) &lt;&lt; std::endl;
     std::cout &lt;&lt; s &lt;&lt; std::endl;
     return 0;
  }
  </code></pre>
  
  <p>Under what conditions should RVO be happening?</p>
  
  <p>btw, I'm basing my question on the following discussion: <a href="http://cpp-next.com/archive/2009/08/want-speed-pass-by-value/" rel="noreferrer">http://cpp-next.com/archive/2009/08/want-speed-pass-by-value/</a></p>