Bug 19223 – core.simd __vector.array compiler crash

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-09-05T08:39:17Z
Last change time
2019-03-12T19:52:26Z
Keywords
pull
Assigned to
No Owner
Creator
Nathan S.
See also
https://issues.dlang.org/show_bug.cgi?id=19224

Comments

Comment #0 by n8sh.secondary — 2018-09-05T08:39:17Z
Following code crashes during compilation: https://run.dlang.io/is/FqDzFp --- int sum(const int[4] val) { int sum = 0; foreach (x; val) sum += x; return sum; } void main() { import core.simd : int4; auto x = sum(int4.init.array); } ---
Comment #1 by iamthewilsonator — 2018-09-28T11:30:27Z
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); }
Comment #2 by ibuclaw — 2019-01-28T23:38:06Z
*** Issue 19607 has been marked as a duplicate of this issue. ***
Comment #3 by dlang-bot — 2019-03-10T13:32:15Z
@ibuclaw created dlang/dmd pull request #9438 "[dmd-cxx] Backport vector array fixes from master" fixing this issue: - fix Issue 19223 - core.simd __vector.array compiler crash https://github.com/dlang/dmd/pull/9438
Comment #4 by dlang-bot — 2019-03-12T19:52:26Z
dlang/dmd pull request #9438 "[dmd-cxx] Backport vector array fixes from master" was merged into dmd-cxx: - b4c3ba558434587abc8f53f8ca41b8ec49b80f4e by Iain Buclaw: fix Issue 19223 - core.simd __vector.array compiler crash https://github.com/dlang/dmd/pull/9438