Discussion Thread: DIP 1040--Copying, Moving, and Forwarding--Community Review Round 1

tsbockman thomas.bockman at gmail.com
Tue Mar 16 23:57:43 UTC 2021


On Thursday, 11 March 2021 at 03:33:31 UTC, Walter Bright wrote:
> The thing about "destroy after move" is to deal with the case 
> of both the source and the destination referring to the same 
> object. The concern is that destroying the destination's 
> original contents first will destroy them for the source before 
> it gets moved in.

I thought of a much simpler way to demonstrate why the DIP's 
proposed move-assignment semantics are unsound:

> After the move is complete, the destructor is called on the
> original contents of the constructed object. The argument is
> invalid after this move, and is not destructed.

In the self-move case, "the original contents of the constructed 
object", "the argument", and the destination are all the same 
thing. So, the DIP requires this one object to be:

1) valid (because it is the destination)
2) "invalid" (because it is "the argument")
3) "not destructed" (because it is "the argument"), and
4) destructed (because it is "the original contents of the 
constructed object")

This is a severe contradiction that needs to be addressed, not 
dismissed with the magic words "as if".

The simple solution is to formally require that self-moves have 
no effect.


More information about the Digitalmars-d mailing list