This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Conditions for NRVO
- From: Clark Gaebel <cgaebel at uwaterloo dot ca>
- To: gcc at gcc dot gnu dot org
- Date: Fri, 31 May 2013 22:23:12 -0400
- Subject: Conditions for NRVO
Hi list!
I was having a discussion with a coworker earlier today about whether
it's safe to say that:
> MyClass some_function()
> {
> MyClass k(/*possibly some arguments here*/);
>
> // Fill up k somehow.
>
> return k;
> }
will never call MyClass' copy constructor, assuming recent versions of
gcc (4.*) and optimizations >= -O1.
Assuming these constraints, are there any cases where the copy
constructor _will_ be called?
- Clark