DIP77 - Fix unsafe RC pass by 'ref'
Walter Bright via Digitalmars-d
digitalmars-d at puremagic.com
Fri Apr 10 14:26:10 PDT 2015
On 4/10/2015 11:28 AM, "Marc =?UTF-8?B?U2Now7x0eiI=?= <schuetzm at gmx.net>" wrote:
> Example:
>
> void foo() @safe {
> RCArray!int arr = [0,1,2];
> {
> int* p = &arr[0]; // legal under new scope rules
This would be a bad design of an RCO. RCO's must be constructed to not allow
pointers to the payload other than by ref.
> RCArray!int other;
> arr = other;
> writeln(*p); // OOPS
> }
> }
More information about the Digitalmars-d
mailing list