DIP77 - Fix unsafe RC pass by 'ref'

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 10 01:46:30 PDT 2015


On 4/10/2015 12:10 AM, "Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= 
<ola.fosheim.grostad+dlang at gmail.com>" wrote:
> On Friday, 10 April 2015 at 07:01:47 UTC, Walter Bright wrote:
>> Nope. It'll scan at compile time the types reachable through the parameters.
>> If any of those types are RCO's that have a type that matches a ref parameter,
>> the ref parameter's RCO will get copied.
>
> But how can this work? If I provide 2 ref parameters to different Node instances
> (not a RCO) in the same graph. How can I then be sure that it will not disappear?
>
> E.g.
>
> ref1 -> Node->RCRef->Edge(RCO)->Node->RCRef->Edge(RCO)->Node"X"
> ref2 -> Node"X"

Because with two parameters, if one is a ref coming from an RCO rc1, and the 
other is a ref to a type that is the root of a graph that contains an RCO type, 
then the rc1 is copied.


More information about the Digitalmars-d mailing list