[Issue 19904] New: move semantics fail through the `emplace` pipeline
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun May 26 17:54:58 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=19904
Issue ID: 19904
Summary: move semantics fail through the `emplace` pipeline
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: major
Priority: P1
Component: druntime
Assignee: nobody at puremagic.com
Reporter: turkeyman at gmail.com
Consider the emplace function:
T* emplace(T, Args...)(T* chunk, auto ref Args args)
if (is(T == struct) || Args.length == 1)
{
import core.internal.lifetime : emplaceRef;
emplaceRef!T(*chunk, args);
return chunk;
}
Note there is no `forward!args` then it is passed to `emplaceRef`. This causes
the arguments to be unnecessarily copied, potentially executing a bunch of copy
code.
Now looking into `emplaceRef` (which I won't paste here because it's a
monster!), you'll see many calls to:
p.__ctor(args);
Note a similar lack of `forward!args` at all the constructor calls, which leads
to a second layer of unnecessary copying.
TL;DR, move semantics in D are woefully broken!
--
More information about the Digitalmars-d-bugs
mailing list