Bug 22766 – copyEmplace does not work with copy constructor and @disable this()

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2022-02-12T11:22:04Z
Last change time
2022-04-13T08:13:32Z
Keywords
pull
Assigned to
No Owner
Creator
Tim

Comments

Comment #0 by tim.dlang — 2022-02-12T11:22:04Z
The following code currently does not compile: import core.lifetime; extern(C++) struct S { @disable this(); this(int) { } this(ref const(S) other) { } } void main() { S s1 = S(1); S s2 = void; copyEmplace(s1, s2); } DMD prints the following error messages: /usr/include/dlang/dmd/core/internal/lifetime.d(18): Error: static assert: "Cannot emplace a S because S.this() is annotated with @disable." /usr/include/dlang/dmd/core/lifetime.d(17): instantiated from here: `emplaceRef!(S, S)` /usr/include/dlang/dmd/core/lifetime.d(1251): instantiated from here: `emplace!(S)` testcopyctor.d(16): instantiated from here: `copyEmplace!(S, S)` The default constructor should not be necessary to use the copy constructor.
Comment #1 by dlang-bot — 2022-04-12T12:49:49Z
@RazvanN7 created dlang/druntime pull request #3799 "Fix Issue 22766 - copyEmplace does not work with copy constructor and @disable this()" fixing this issue: - Fix Issue 22766 - copyEmplace does not work with copy constructor and @disable this() https://github.com/dlang/druntime/pull/3799
Comment #2 by dlang-bot — 2022-04-13T08:13:32Z
dlang/druntime pull request #3799 "Fix Issue 22766 - copyEmplace does not work with copy constructor and @disable this()" was merged into master: - e815ab7abd4fa04bcb698cbf635a1caa25aa3061 by RazvanN7: Fix Issue 22766 - copyEmplace does not work with copy constructor and @disable this() https://github.com/dlang/druntime/pull/3799