[Issue 9985] Postblit isn't called on local struct return

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Apr 24 14:49:39 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9985



--- Comment #4 from Sebastian Graf <SebastianGraf at t-online.de> 2013-04-24 14:49:37 PDT ---
(In reply to comment #3)
> 
> I could be mistaken, but the "&s == &__retval" would be the "C++ NRVO". Since D
> is allowed to move things, it just detects that, and does a postblit-less
> memcopy, which is relatively simple and cheap.

Yeah, I meant NRVO in a C++ sense. So D doesn't attempt that and instead relies
on copying the struct without side effects, thus eliding destructors and
postblit.
Still seems awkward to me, why not just leave out copying all along? Or is
memcpy really that fast? If not, is this a potential optimization for the
future?

Sorry to hijack this into a learning thread. Feel free to close it any time.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list