When D feels unfinished: union initialization and NRVO
kinke
noone at nowhere.com
Thu Mar 19 17:57:46 UTC 2020
On Thursday, 19 March 2020 at 17:38:42 UTC, Mathias Lang wrote:
> From my tests, it seems to do NRVO on LDC, so I suppose you
> recognize it ?
> On DMD, it just does a blit, which can still be expensive and
> breaks interior pointers.
Yeah, I'd suggest not to look at how this is currently
implemented (Walter doesn't seem to see the advantage of a move
compiler intrinsic). With a proper optimizer, you shouldn't have
to care (see LDC result).
Wrt. interior pointers, that's in the spec and could bite you in
different places where moving is implicit.
> I also found out that one of the earlier case I mentioned
> (https://gist.github.com/Geod24/61ef0d8c57c3916cd3dd7611eac8234e#file-nrvo_struct_ctor-d) only does NRVO on LDC. DMD (and GDC 9.3.0) just silently move it.
I've been working on improving things in this regard, especially
with v1.19.
More information about the Digitalmars-d
mailing list