https://issues.dlang.org/show_bug.cgi?id=17448

--- Comment #12 from Walter Bright <bugzi...@digitalmars.com> ---
Interestingly, if you change:

  auto f() {
    return CallContext(18);
  }

to:

  auto f() {
    CallContext c = CallContext(18);
    return c;
  }

it will work, i.e. no moving is done. This is because the compiler does NRVO
(Named Return Value Optimization) on it, where the object is constructed
directly into its final destination.

It's obviously not doing this for the original return statement, likely because
it does not have a name :-)

I'll look into correcting this, as NRVO is an important optimization. But at
least you have a workaround for the moment.

--

Reply via email to