D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 19607 - [ICE] dmd/e2ir.d(117): Invalid type mTYconst|TYstruct
Summary: [ICE] dmd/e2ir.d(117): Invalid type mTYconst|TYstruct
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 critical
Assignee: No Owner
URL:
Keywords: ice-on-valid-code, pull
Depends on:
Blocks:
 
Reported: 2019-01-23 17:43 UTC by Iain Buclaw
Modified: 2019-03-12 19:52 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Iain Buclaw 2019-01-23 17:43:26 UTC
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 Iain Buclaw 2019-01-27 01:39:59 UTC
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 Iain Buclaw 2019-01-28 23:38:06 UTC
It is at this point I realise this is a duplicate.

*** This issue has been marked as a duplicate of issue 19223 ***
Comment 3 Iain Buclaw 2019-01-28 23:41:34 UTC
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 Dlang Bot 2019-03-10 13:32:17 UTC
@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 Dlang Bot 2019-03-12 19:52:28 UTC
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