Bug 19607 – [ICE] dmd/e2ir.d(117): Invalid type mTYconst|TYstruct

Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-01-23T17:43:26Z
Last change time
2019-03-12T19:52:28Z
Keywords
ice-on-valid-code, pull
Assigned to
No Owner
Creator
Iain Buclaw

Comments

Comment #0 by ibuclaw — 2019-01-23T17:43:26Z
Minimal test --- int f (const int[4] x) { int sum = 0; foreach (i; x) sum += i; return sum; } void main () { import core.simd : int4; f(int4.init.array); } --- When ENABLE_RELEASE=1 el:0x557aa7612570 cnt=0 cs=0 const mTYconst|TYstruct Invalid type mTYconst|TYstruct Segmentation fault When ENABLE_DEBUG=1 core.exception.AssertError@dmd/e2ir.d(117): Assertion failure ---------------- ??:? _d_assertp [0x5ebe53fd] ??:? _Z11useOPstrparP4elem [0x5eb0062d] ??:? _Z8callfuncRK3LocP7IRStateiP4TypeP4elemS5_P15FuncDeclarationS5_S7_P5ArrayIP10ExpressionES7_ [0x5eb00c56] ??:? _ZN6toElem13ToElemVisitor5visitEP7CallExp [0x5eb0bf5c] ??:? _ZN7CallExp6acceptEP7Visitor [0x5ea0a3b9] ??:? _Z6toElemP10ExpressionP7IRState [0x5eb027bc] ??:? _Z10toElemDtorP10ExpressionP7IRState [0x5eb10fc8] ??:? _ZN11S2irVisitor5visitEP12ExpStatement [0x5eafa7b2] ??:? _ZN12ExpStatement6acceptEP7Visitor [0x5eab35e5] ??:? _Z14Statement_toIRP9StatementP7IRState [0x5eafc84c] ??:? _ZN11S2irVisitor5visitEP17CompoundStatement [0x5eafa83b] ??:? _ZN17CompoundStatement6acceptEP7Visitor [0x5eab3db5] ??:? _Z14Statement_toIRP9StatementP7IRState [0x5eafc84c] ??:? _ZN11S2irVisitor5visitEP17CompoundStatement [0x5eafa83b] ??:? _ZN17CompoundStatement6acceptEP7Visitor [0x5eab3db5] ??:? _Z14Statement_toIRP9StatementP7IRState [0x5eafc84c] ??:? _Z25FuncDeclaration_toObjFileP15FuncDeclarationb [0x5eaefdea] ??:? _ZN9toObjFile9ToObjFile5visitEP15FuncDeclaration [0x5eafd794] ??:? _ZN15FuncDeclaration6acceptEP7Visitor [0x5ea37135] ??:? _Z9toObjFileP7Dsymbolb [0x5eafd6fd] ??:? _Z10genObjFileP6Moduleb [0x5eaee3af] ??:? int dmd.mars.tryMain(ulong, const(char)**, ref dmd.globals.Param) [0x5ea7c377] ??:? _Dmain [0x5ea7cf54]
Comment #1 by ibuclaw — 2019-01-27T01:39:59Z
TypeVector::dotExp is the culprit, the front-end is type punning a VectorExp as a normal array. Correct codegen would just make a copy of the underlying array literal.
Comment #2 by ibuclaw — 2019-01-28T23:38:06Z
It is at this point I realise this is a duplicate. *** This issue has been marked as a duplicate of issue 19223 ***
Comment #3 by ibuclaw — 2019-01-28T23:41:34Z
Actually, I'll make this variant, which also ICE's. int f (const int[4] x) { int sum = 0; foreach (i; x) sum += i; return sum; } void main () { import core.simd : int4; f(int4(2).array); }
Comment #4 by dlang-bot — 2019-03-10T13:32:17Z
@ibuclaw created dlang/dmd pull request #9438 "[dmd-cxx] Backport vector array fixes from master" fixing this issue: - fix Issue 19607 - [ICE] dmd/e2ir.d(117): Invalid type mTYconst|TYstruct https://github.com/dlang/dmd/pull/9438
Comment #5 by dlang-bot — 2019-03-12T19:52:28Z
dlang/dmd pull request #9438 "[dmd-cxx] Backport vector array fixes from master" was merged into dmd-cxx: - 4b95edb5fa40b3dadee1b9a58a0a6ff97f2e3463 by Iain Buclaw: fix Issue 19607 - [ICE] dmd/e2ir.d(117): Invalid type mTYconst|TYstruct https://github.com/dlang/dmd/pull/9438