[Issue 13118] Allow non-`@nogc` stuff in `@nogc` function contracts

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Jul 13 02:56:31 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=13118

--- Comment #2 from Denis Shelomovskij <verylonglogin.reg at gmail.com> ---
(In reply to bearophile_hugs from comment #1)
> (In reply to Denis Shelomovskij from comment #0)
> > This code should compile:
> > ---
> > void f() @nogc
> > in { new int; }
> > body { }
> > ---
> > 
> > Note this is already the case for `nothrow` functions as one can throw
> > `Exception`s in contracts which allows e.g. use `assert(expr, format(...))`.
> 
> I think this is a bad idea. The point of @nogc is to be sure the GC will not
> be called or used inside a piece of code. This ER invalidates that. For this
> ER to be accepted I'll want a @reallynogc added to D that really forbids the
> use of GC.

I don't see any difference here with `nothrow` which can be violated in
contracts allowing e.g. `format` calls.

--


More information about the Digitalmars-d-bugs mailing list