[Issue 21317] Copy constructor defined but blitting still occurs
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Oct 20 03:13:55 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=21317
RazvanN <razvan.nitu1305 at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |razvan.nitu1305 at gmail.com
Resolution|--- |INVALID
--- Comment #1 from RazvanN <razvan.nitu1305 at gmail.com> ---
The copy constructor DIP specifies that the copy constructor may be called only
in the case of lvalues; in the case of rvalues a move is performed implicitly.
The cited paragraph: "When a copy constructor is defined for a struct, all
implicit blitting is disabled for that struct" was referring only to lvalues
because that is where you would normally call a copy constructor (although, I
agree that the wording should have been better).
In this situation the compiler constructs S(1) in the stack of f and then does
a move. This is not optimal, but it has nothing to do with copy constructors.
Since you already filed an enhancement request for this code, I am going to
close this issue as it has nothing to do with copy constructors.
--
More information about the Digitalmars-d-bugs
mailing list