Boost logo

Boost :

Subject: Re: [boost] [operators] The Dangling Reference Polarization
From: Daniel Frey (d.frey_at_[hidden])
Date: 2013-05-04 18:36:03

On 04.05.2013, at 21:45, Michael Marcin <mike.marcin_at_[hidden]> wrote:

> Here is another data point:
> And here are msvc11 results:
> based on:

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.

Boost list run by bdawes at, gregod at, cpdaniel at, john at