@gc attribute for bypassign @nogc
ketmar via Digitalmars-d
digitalmars-d at puremagic.com
Sun Jul 24 17:41:31 PDT 2016
On Monday, 25 July 2016 at 00:26:05 UTC, bitwise wrote:
> If someone knows all their code is @nogc, they can disable the
> GC. If they do that, and then someone GC allocates anyways,
> it's a leak. Based on this, an argument could be made that
> @nogc should *never* be bypassed. But that argument is made on
> the false premise that it's fool-proof in it's current
> condition. It's not, because you can already use malloc() in a
> @nogc function and leak that memory instead.
`@nogc` should not be bypassed due to completely different
reasons. while compiler is not doing any optimizations or
generating any GC helpers for gc code now, it *can* do that in
the future, so cheating the compiler is bad idea.
otherwise, `@nogc` doesn't really guarantee absence of memory
leaks, and it wasn't designed to do so.
More information about the Digitalmars-d
mailing list