On 04.05.2013, at 21:45, Michael Marcin
Here is another data point: http://ideone.com/GgaZZV
And here are msvc11 results: http://codepad.org/XFT5qVyE
based on: http://stackoverflow.com/questions/1693005/copy-elision-on-visual-c-2010-bet...
From what I can see these are some more basic tests and they confirm that copy elision does not take place for pass-by-value (for MSVC, but my tests also confirmed that for GCC/Clang), i.e., the last test case "identity( rvalue() )" does not eliminate the temporary. Is there anything else that can be learned from the above that I missed? BTW: Careful when testing the (N)RVO on earlier versions of MSVC/GCC, I seem to remember that some compilers where allergic to any code before the named variable that was returned. In code: X foo() { X x; scope_logger sl(); return x; } // compiler performed the NRVO X foo() { scope_logger sl(); X x; return x; } // no NRVO Although this does not seem to be a problem for MSVC11 or any recent version of GCC.