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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Apr 25 03:37:50 PDT 2013


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



--- Comment #8 from monarchdodra at gmail.com 2013-04-25 03:37:48 PDT ---
(In reply to comment #6)
> (In reply to comment #0)
> > Maybe this is a bug in RVO?
> 
> This is a compiler bug at the intersection of the deduction for `auto ref` and
> NRVO.

Could you clarify the "This is a compiler bug"? Are you saying this is an
actual bug according to spec, or just that a "missed optimization opportunity"
?

In particular, if I compile using "S" instead of "auto ref", then NRVO only
triggers in release. However, in non release, postblit still doesn't get
called.

This is the correct behavior, correct? In non-release, there is no NRVO, but no
postblit either, so the code is wrong according to spec?

================

I also want to note that the "NRVO fix" does not actually fix the original
code, as passing a temp by value doesn't postblit. This will still fail, even
in release, even with NRVO:

//--------
void doIt(S9985 s)   
{
    assert(S9985.ptr == &s); //Passed without postblit, fails here

}
void main()
{
    doIt(makeS9985());
}
//--------

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