Debug prints in @nogc

ag0aep6g via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Aug 31 12:39:36 PDT 2016


On 08/31/2016 09:23 PM, Yuxuan Shui wrote:
> Correct me if I'm wrong. But I believe this is only true when the source
> code of function is not available. Otherwise the compiler should always
> know if a function is actually @nogc or not.

Attributes are only inferred in certain cases where the source code must 
be available anyway (templates, `auto` return value). For ordinary 
functions, the compiler only considers them @nogc when they're 
explicitly marked.

For example, the compiler won't let you do this, even though f's source 
code is available and it's obviously de-facto @nogc:

----
void f() {}
void main() @nogc { f(); }
----


More information about the Digitalmars-d-learn mailing list