@trusted and return ref

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Feb 27 06:52:56 PST 2015


On 2/27/15 3:29 AM, Kagamin wrote:
> On Thursday, 26 February 2015 at 16:25:59 UTC, Steven Schveighoffer wrote:
>> However, we have an issue here. At any point inside the code, you
>> could do:
>>
>> oldcount = count;
>>
>> And now, there is still potentially a dangling pointer somewhere. This
>> means every place count is used must be checked. In this case, all
>> uses of count have to be re-checked when the file is edited.
>>
>> Because count leaks the memory details of the trusted call to free (In
>> other words, the fact that count, or any copy of it, can become a
>> dangling pointer), I believe every call in that type that deals with
>> count should be marked trusted.
>
> The counter is freed in the destructor, nothing can happen after that.

So the code is now etched in stone and cannot be changed? Is there an 
attribute for that? :P

-Steve


More information about the Digitalmars-d-learn mailing list