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

Walter Bright newshound2 at digitalmars.com
Sun Mar 21 00:18:43 UTC 2021


On 3/20/2021 8:12 AM, H. S. Teoh wrote:
> Is there a typo somewhere here?  I'm *pretty* sure the current compiler
> *does* move structs in some cases, and that has caused problems in the
> past where structs that store pointers to themselves will end up with
> dangling pointers after, e.g., being returned from a function.

It doesn't. Even in the case of NRVO, it doesn't actually move them.

The main reason it doesn't is because data flow analysis is necessary to see if 
it can be moved (no pointers to the source object). In order to determine "last 
use", DFA is used.


More information about the Digitalmars-d mailing list