https://issues.dlang.org/show_bug.cgi?id=19872
Issue ID: 19872
Summary: Copy constructor: Order of declaration yields
different results with rvalue constructor
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: blocker
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
The code below contains identical struct declarations except for the order of
the constructors in the body. Yet, `Ok` compiles file and `Oops` does not:
----------------------
struct Ok {
this(ref Ok other);
this(Ok other);
}
struct Oops {
this(Oops other);
this(ref Oops other);
}
----------------------
bug.d(7): Error: struct Oops may not define both a rvalue constructor and a
copy constructor
bug.d(8): rvalue constructor defined here
bug.d(9): copy constructor defined here
The order shouldn't make a difference on whether or not the code compiles, but
nearly as importantly: *why* wouldn't one be able to declare both a copy
constructor and an rvalue one? How else would one have both copy and move
semantics?
--