https://issues.dlang.org/show_bug.cgi?id=19223
Nicholas Wilson <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] | |m --- Comment #1 from Nicholas Wilson <[email protected]> --- 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); } --
