Question about @nogc in D 2.066

Weasel via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jul 11 13:02:30 PDT 2014


@nogc
void main(string[] args)
{
     immutable(char)[] s1 = "hello";
     immutable(int)[] a1 = [1, 2];
}

Why does the s1 not throw an error, but the a1 does? As far as I 
can tell, they're both immutable arrays.

Error is: "Error: array literal @nogc function main may cause GC 
allocation"

It compiles fine if I comment out the second line in main.


More information about the Digitalmars-d-learn mailing list