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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Apr 24 14:37:56 PDT 2013


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



--- Comment #3 from monarchdodra at gmail.com 2013-04-24 14:37:55 PDT ---
(In reply to comment #2)
> I stumbled over this when using a C library and it got me plenty time to trace
> it back. Seems like after all I missed one of those tiny spec details.
> 
> Anyhow, I even had a look at the generated assembly on windows, with/without
> optimization.
> There seems to be no NRVO applied, since makeS() does 2 copies (rep movsd), one
> to copy S.init into s and one to copy s into __retval at exit. I may be
> mistaken, but isn't the point of NRVO to make &s == &__retval, thus only
> needing to copy S.init into &__retval?

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.

-- 
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