Memory safety depends entirely on GC ?

Peter Alexander via Digitalmars-d digitalmars-d at puremagic.com
Sat Feb 21 14:13:08 PST 2015


On Saturday, 21 February 2015 at 20:13:26 UTC, deadalnix wrote:
> On Saturday, 21 February 2015 at 19:38:02 UTC, Peter Alexander 
> wrote:
>> @safe @nogc
>>
>> :-)
>>
>> (I rewrote the post a few times. Originally I just wrote "mark 
>> main @safe @nogc and you're fine", but I think it's a bit 
>> misleading since @nogc is still difficult to use, so I wrote 
>> about that instead and forgot to mention @safe at all. Thanks 
>> for pointing out.)
>
> free is an unsafe operation. Unless you don't allocate at all 
> or choose to leak everything, you won't be able to be safe and 
> nogc.
>
> The only way out that I know of is an ownership system.

malloc+free can be trusted if wrapped in something like a ref 
counted pointer, no?


More information about the Digitalmars-d mailing list