[Issue 11287] NRVO should remove dtor call completely

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Oct 17 06:48:37 PDT 2013


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



--- Comment #2 from Kenji Hara <k.hara.pg at gmail.com> 2013-10-17 06:48:36 PDT ---
(In reply to comment #1)
> Question:
> 
> Doesn't this mean that the compiler *must* implement NRVO? I thought NRVO was
> an optimization *opportunity*?
> 
> If
> //----
> A getA() pure
> {
>     A a;        // line 7
>     return a;   // NRVO
> }
> //----
> 
> Is legal, then it means that only compilers hat implement NRVO will handle
> this.
> 
> Sorry if it's a stupid question.

Unfortunately current D language spec does not mention about NRVO, so It's
still one of the optimizations. But, at least, current dmd always apply NRVO
for the specific test case.

And, in D we can check the semantic analysis result by using is(typeof()) and
__traits(compiles). I believe that "if these compile-time checker primitives
return true, it should mean that the specific D code will generate correct
runtime code, and vice versa". For example, since "cannot access frame pointer"
error had not been able to detect in compile-time, but now it can.

Back to the case, dmd could generate correct binary for the code by using NRVO.
So dmd should not cause "cannot call impure function" error.

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