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

          Issue ID: 24072
           Summary: cast(__vector) array literal incorrectly triggers GC
                    error
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nob...@puremagic.com
          Reporter: johanenge...@weka.io

Testcase:
```
import core.simd;

struct Mins {
    int4 val;
}

void OK() @nogc {
    Mins b = Mins([1,2,3,4]);
}

void not_OK() @nogc {
    Mins b = Mins(cast(__vector(int[4]))[1,2,3,4]);
}
```

gives error:
<source>(12): Error: array literal in @nogc function example.not_OK may cause a
GC allocation

But this code does not trigger GC allocation of the array, and thus should be
accepted.  `cast(int[4])` does work, so that logic should be extended to allow
casting to vector types.

--

Reply via email to