On Tuesday, 3 May 2022 at 12:59:31 UTC, Alain De Vos wrote:
Error: array literal in @nogc function test.myfun may cause a GC allocation

@nogc void myfun(){
        scope int[] i=[1,2,3];
}//myfun

May is a fuzzy word...

For this particular piece of code, you can use a static array to guarantee the usage of stack allocation

```d
import std;
@nogc void myfun(){
/* no need to use scope now */int[3] i=[1,2,3];//this now compiles

}//myfun

void main()
{
    writeln("Hello D");
}
```


Reply via email to