DIP77 - Fix unsafe RC pass by 'ref'
Walter Bright via Digitalmars-d
digitalmars-d at puremagic.com
Fri Apr 10 10:32:55 PDT 2015
On 4/10/2015 4:49 AM, Michel Fortin wrote:
> ...or maybe not. Let's add another field to Big:
>
> struct Handle
> {
> // shouldn't be able to make copies of this
> @disable this(this) {}
> }
>
> struct Big
> {
> RCArray!T array;
> int[1000] ints;
> Handle handle;
> }
>
> Now Big's implicit postblit becomes disabled too (because Handle can't handle
> copying), therefore it is no longer a RCO object and the compiler will no longer
> create temporary copies. Now you've trashed memory-safety.
The copy would be made of array, not Big.
More information about the Digitalmars-d
mailing list