Memory safety depends entirely on GC ?

Peter Alexander via Digitalmars-d digitalmars-d at puremagic.com
Sun Feb 22 06:41:41 PST 2015


On Sunday, 22 February 2015 at 04:19:32 UTC, deadalnix wrote:
> On Saturday, 21 February 2015 at 22:13:09 UTC, Peter Alexander 
> wrote:
>> malloc+free can be trusted if wrapped in something like a ref 
>> counted pointer, no?
>
> Foo bazoom;
>
> class Foo {
>     void bar() {
>         bazoom = this;
>     }
> }
>
> void foo() {
>     RefCounted!Foo f = ...
>     f.bar();
>
>     // bazoom is now a dandling pointer.
> }

I see, thanks.

Is assigning 'this' from a member function the only problem case?




More information about the Digitalmars-d mailing list