October 20, 2020 [Issue 21317] Copy constructor defined but blitting still occurs | ||||
|---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=21317 RazvanN <razvan.nitu1305@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |razvan.nitu1305@gmail.com Resolution|--- |INVALID --- Comment #1 from RazvanN <razvan.nitu1305@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. -- | ||||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply