https://issues.dlang.org/show_bug.cgi?id=16131
Issue ID: 16131
Summary: A struct is being copied unnecessarily when
initialized
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
Even when the struct disallows copying, it is being temporarily created and
copied. This reproduces on both dmd and ldc2.
Reproducing example:
struct Foo {
@disable this(this);
this(out Foo *x) { x = &this; }
}
void main() {
Foo *x;
auto a = Foo(x);
assert(x == &a); // OK
Foo b;
b = Foo(x);
assert(x == &b); // FAILS
}
--