[Issue 24072] New: cast(__vector) array literal incorrectly triggers GC error

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Aug 5 10:36:59 UTC 2023


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: nobody at puremagic.com
          Reporter: johanengelen at 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.

--


More information about the Digitalmars-d-bugs mailing list