This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]