D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 22766 - copyEmplace does not work with copy constructor and @disable this()
Summary: copyEmplace does not work with copy constructor and @disable this()
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: druntime (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 enhancement
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2022-02-12 11:22 UTC by Tim
Modified: 2022-04-13 08:13 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Tim 2022-02-12 11:22:04 UTC
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 Dlang Bot 2022-04-12 12:49:49 UTC
@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 Dlang Bot 2022-04-13 08:13:32 UTC
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