[Issue 19223] core.simd __vector.array compiler crash

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Sep 28 11:30:27 UTC 2018


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

Nicholas Wilson <iamthewilsonator at hotmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |iamthewilsonator at hotmail.co
                   |                            |m

--- Comment #1 from Nicholas Wilson <iamthewilsonator at hotmail.com> ---
reduced to 

---
void sum(int[4] val)
{
}

void main()
{
    import core.simd : int4;
    sum(int4.init.array);
}
---
 trips an assert in dmd/e2ir.d(117):

private elem *useOPstrpar(elem *e)
{
    tym_t ty = tybasic(e.Ety);
    if (ty == TYstruct || ty == TYarray)
    {
        e = el_una(OPstrpar, TYstruct, e);
        e.ET = e.EV.E1.ET;
        assert(e.ET); // <--- Here
    }
    return e;
}

AST reveals that 
sum(int4.init.array);
becomes

sum(cast(__vector(int[4]))[0, 0, 0, 0]);

which obviously does not pass semantic.

sum((cast(__vector(int[4]))[0, 0, 0, 0]).array); // Error: cannot resolve type
for cast(__vector(int[4]))[0, 0, 0, 0]

auto x = (cast(__vector(int[4]))[0, 0, 0, 0]; // Error: cannot resolve type for
cast(__vector(int[4]))[0, 0, 0, 0]
which is bogus.

Workaround 

int sum(const int[4] val)
{
    int sum = 0;
    foreach (x; val) sum += x;
    return sum;
}

void main()
{
    import core.simd : int4;
    auto x = int4.init;
    sum(x.array);
}

--


More information about the Digitalmars-d-bugs mailing list