https://issues.dlang.org/show_bug.cgi?id=22614
Issue ID: 22614
Summary: Wrong copy constructor is called depending on context
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: blocker
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
@safe // <- comment this @safe, and both asserts pass
unittest
{
static struct S
{
int i;
this(int i) { this.i = i; }
this(ref const S) { i = 2; }
this(ref S) immutable { i = 3; }
}
auto source = S(1);
auto implicit = source;
S explicit;
explicit.__ctor(source);
assert(implicit.i == 2);
assert(explicit.i == 2);
}
This is blocking implementation of dup/idup for arrays that would correctly
support copy constructors.
(The unittest is actually adapted from existing one in druntime).
--