new int[]

Nathan S. no.public.email at example.com
Wed Jan 10 22:50:22 UTC 2018


On Wednesday, 10 January 2018 at 22:46:30 UTC, ag0aep6g wrote:
> If I understand correctly, the goal is to have the `int[]` 
> itself on the GC heap.

The code
----
void main(string[] args) @nogc
{
     int[] x = [1, 2, 3];
}
----

won't compile, because "array literal in @nogc function 'D main' 
may cause GC allocation". But "may" isn't the same as "will". 
What determines it? That's a kind of goofy error message now that 
I think about it.



More information about the Digitalmars-d-learn mailing list