www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18713] New: ICE in dmd/statementsem.d:1798 with -dip1000

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

          Issue ID: 18713
           Summary: ICE in dmd/statementsem.d:1798 with -dip1000
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: blocker
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: greensunny12 gmail.com

Observed here: https://github.com/dlang/phobos/pull/4990

Reduced sample:
(Compile with -dip1000)

---
ParallelForeach!R parallel(R)(R)
{
}

void main()
{
    auto arrIndex = new int;
    parallel(arrIndex).each!(i => e);
}

struct ParallelForeach(R)
{
    alias E = R;

    alias IndexDg = int delegate(E);
    int opApply(IndexDg)
    {
    }
}

template each(alias pred)
{
    enum isForeachUnaryIterable(R)(R r)
    {
        foreach (a; r)
            unaryFun;
    };

    enum isForeachIterable(R) = isForeachUnaryIterable!R;

    void each(Range)(Range) if (isForeachIterable!Range)
    {
    }

    void each()
    {
    }
}
---


---
0x00005555558ca61f in StatementSemanticVisitor::visit(ForeachStatement*)
(this=0x7fffffff6bf8, fs=0x7fffee4d38b0) at dmd/statementsem.d:1798
1798                            ++flde.fd.tookAddressOf;  // allocate a closure
unless the opApply() uses 'scope'

(this=0x7fffffff6bf8, fs=0x7fffee4d38b0) at dmd/statementsem.d:1798

(this=0x7fffee4d38b0, v=0x7fffffff6bf8) at dmd/statement.d:1301

(s=0x7fffee4d38b0, sc=0x7fffee4c7750) at dmd/statementsem.d:127

(this=0x7fffffff6ef8, cs=0x7fffee4d3cf0) at dmd/statementsem.d:236

(this=0x7fffee4d3cf0, v=0x7fffffff6ef8) at dmd/statement.d:908

(s=0x7fffee4d3cf0, sc=0x7fffee4c7750) at dmd/statementsem.d:127

(this=0x7fffffff7870, funcdecl=0x7fffee4d3460) at dmd/semantic3.d:581

ParseTimeVisitor<ASTCodegen>::visit(FuncLiteralDeclaration*)
(this=0x7fffffff7870, s=0x7fffee4d3460) at dmd/parsetimevisitor.d:51

(this=0x7fffee4d3460, v=0x7fffffff7870) at dmd/func.d:3144

sc=0x7fffee4ab060) at dmd/semantic3.d:83

(this=0x7fffffff79b8, exp=0x7fffee4d3420) at dmd/expressionsem.d:2610

v=0x7fffffff79b8) at dmd/expression.d:4656

(e=0x7fffee4d3420, sc=0x7fffee4a3650) at dmd/expressionsem.d:9367

(this=0x7fffffff7ac0, mt=0x7fffee4d3360) at dmd/typesem.d:2369

v=0x7fffffff7ac0) at dmd/mtype.d:5785

Type**, Dsymbol**, bool) (mt=0x7fffee4d3360, loc=..., sc=0x7fffee49bea0,
pe=0x7fffffff7b58, pt=0x7fffffff7b60, ps=0x7fffffff7b68, intypeid=false) at
dmd/typesem.d:2075

(this=0x7fffffff7bd0, mtype=0x7fffee4d3360) at dmd/typesem.d:1299

v=0x7fffffff7bd0) at dmd/mtype.d:5785

loc=..., sc=0x7fffee49bea0) at dmd/typesem.d:147

(this=0x7fffee4d3360, loc=..., sc=0x7fffee49bea0) at dmd/mtype.d:947

(this=0x7fffffff7ec8, e=0x7fffee4d3300) at dmd/expressionsem.d:3823

v=0x7fffffff7ec8) at dmd/expression.d:4802

(e=0x7fffee4d3300, sc=0x7fffee49b600) at dmd/expressionsem.d:9367

(this=0x7fffffff8008, init=0x7fffee4d32d0) at dmd/initsem.d:658

(this=0x7fffee4d32d0, v=0x7fffffff8008) at dmd/init.d:322

sc=0x7fffee49b600) at dmd/initsem.d:51

(this=0x7fffffff86b0, dsym=0x7fffee4d31b0) at dmd/dsymbolsem.d:583

(this=0x7fffee4d31b0, v=0x7fffffff86b0) at dmd/declaration.d:1612

(dsym=0x7fffee4d31b0, sc=0x7fffee484750) at dmd/dsymbolsem.d:343

(this=0x7fffee4494b0, sc2=0x7fffee484750) at dmd/dtemplate.d:7487

(this=0x7fffee4494b0, sc2=0x7fffee484750) at dmd/dtemplate.d:7505

_D3dmd10dsymbolsem24templateInstanceSemanticFCQBs9dtemplate16TemplateInstancePSQCz6dscope5ScopePSQDr4root5array__T5ArrayTCQEq10expression10ExpressionZQBkZv
(fargs=0x0, sc=0x7fffee449890, tempinst=0x7fffee4494b0) at
dmd/dsymbolsem.d:5500

(this=0x7fffffff8aa0, ti=0x7fffee4494b0) at dmd/dsymbolsem.d:2474

(this=0x7fffee4494b0, v=0x7fffffff8aa0) at dmd/dtemplate.d:7534

(dsym=0x7fffee4494b0, sc=0x7fffee449890) at dmd/dsymbolsem.d:343

(this=0x7fffffff8c88, exp=0x7fffee449480) at dmd/expressionsem.d:1926

v=0x7fffffff8c88) at dmd/expression.d:4067

(e=0x7fffee449480, sc=0x7fffee449890) at dmd/expressionsem.d:9367

(this=0x7fffffff8d68, exp=0x555557814db0) at dmd/expressionsem.d:8652

v=0x7fffffff8d68) at dmd/expression.d:6913

(e=0x555557814db0, sc=0x7fffee449890) at dmd/expressionsem.d:9367

(this=0x7fffffff8e48, exp=0x555557814cd0) at dmd/expressionsem.d:8652

v=0x7fffffff8e48) at dmd/expression.d:6913

(e=0x555557814cd0, sc=0x7fffee449890) at dmd/expressionsem.d:9367

(this=0x7fffffff8f88, init=0x7fffee448a90) at dmd/initsem.d:658

(this=0x7fffee448a90, v=0x7fffffff8f88) at dmd/init.d:322

sc=0x7fffee449890) at dmd/initsem.d:51

(this=0x7fffffff9630, dsym=0x7fffee448970) at dmd/dsymbolsem.d:583

(this=0x7fffee448970, v=0x7fffffff9630) at dmd/declaration.d:1612

(dsym=0x7fffee448970, sc=0x7fffee447f40) at dmd/dsymbolsem.d:343

(this=0x7fffee4481b0, sc2=0x7fffee447f40) at dmd/dtemplate.d:7487

(this=0x7fffee4481b0, sc2=0x7fffee447f40) at dmd/dtemplate.d:7505

_D3dmd10dsymbolsem24templateInstanceSemanticFCQBs9dtemplate16TemplateInstancePSQCz6dscope5ScopePSQDr4root5array__T5ArrayTCQEq10expression10ExpressionZQBkZv
(fargs=0x0, sc=0x7fffee4474c0, tempinst=0x7fffee4481b0) at
dmd/dsymbolsem.d:5500

(this=0x7fffffff9a20, ti=0x7fffee4481b0) at dmd/dsymbolsem.d:2474

(this=0x7fffee4481b0, v=0x7fffffff9a20) at dmd/dtemplate.d:7534

(dsym=0x7fffee4481b0, sc=0x7fffee4474c0) at dmd/dsymbolsem.d:343

(this=0x7fffffff9c08, exp=0x7fffee448180) at dmd/expressionsem.d:1926

v=0x7fffffff9c08) at dmd/expression.d:4067

(e=0x7fffee448180, sc=0x7fffee4474c0) at dmd/expressionsem.d:9367

_D3dmd13expressionsem11unaSemanticFCQBi10expression6UnaExpPSQCg6dscope5ScopeZCQCyQBq10Expression
(sc=0x7fffee4474c0, e=0x5555578143e0) at dmd/expressionsem.d:9313

(this=0x7fffffff9d08, e=0x5555578143e0) at dmd/expressionsem.d:5097

v=0x7fffffff9d08) at dmd/expression.d:5781

(e=0x5555578143e0, sc=0x7fffee4474c0) at dmd/expressionsem.d:9367

_D3dmd10staticcond19evalStaticConditionFPSQBo6dscope5ScopeCQCf10expression10ExpressionQBcKbZb
(errors= 0x7fffffff9f28: false, e=0x5555578143e0, exp=0x555557812d40,
sc=0x7fffee4474c0) at dmd/staticcond.d:82

_D3dmd10staticcond19evalStaticConditionFPSQBo6dscope5ScopeCQCf10expression10ExpressionQBcKbZb
(errors= 0x7fffffff9f28: false, e=0x555557814b40, exp=0x555557812d40,
sc=0x7fffee4473b0) at dmd/staticcond.d:49

TemplateDeclaration::evaluateConstraint(TemplateInstance*, Scope*, Scope*,
Array<RootObject*>*, FuncDeclaration*) (this=0x7fffee43f3e0, ti=0x7fffee447720,
sc=0x7fffee5ca260, paramscope=0x7fffee447110, dedargs=0x7fffee447880,
fd=0x7fffee447b00) at dmd/dtemplate.d:778

TemplateDeclaration::deduceFunctionTemplateMatch(TemplateInstance*, Scope*,
FuncDeclaration*&, Type*, Array<Expression*>*) (this=0x7fffee43f3e0,
ti=0x7fffee447720, sc=0x7fffee5ca260, fd= 0x7fffffffa7f0: 0x7fffee447b00,
tthis=0x0, fargs=0x7fffee6398e0) at dmd/dtemplate.d:1982

_D3dmd9dtemplate15functionResolveFPSQBi11declaration5MatchCQCf7dsymbol7DsymbolSQCz7globals3LocPSQDq6dscope5ScopePSQEi4root5array__T5ArrayTCQFhQz10rootobject10RootObjectZQBmCQGp5mtype4TypePSQHfQCxQCv__TQCsTCQHw10expression10ExpressionZQDzPPxaZ13applyTemplateMFCQJyQJx19TemplateDeclarationZi
(this=0x7fffffffa9e0, td=0x7fffee43f3e0) at dmd/dtemplate.d:2690

_D3dmd9dtemplate15functionResolveFPSQBi11declaration5MatchCQCf7dsymbol7DsymbolSQCz7globals3LocPSQDq6dscope5ScopePSQEi4root5array__T5ArrayTCQFhQz10rootobject10RootObjectZQBmCQGp5mtype4TypePSQHfQCxQCv__TQCsTCQHw10expression10ExpressionZQDzPPxaZ10__lambda11MFQHqZi
(this=0x7fffffffa9e0, s=0x7fffee43f3e0) at dmd/dtemplate.d:2797

_D3dmd4func13overloadApplyFCQBa7dsymbol7DsymbolMDFQxZiPSQCc6dscope5ScopeZi
(sc=0x7fffee5ca260, dg=..., fstart=0x7fffee43f3e0) at dmd/func.d:2414

_D3dmd9dtemplate15functionResolveFPSQBi11declaration5MatchCQCf7dsymbol7DsymbolSQCz7globals3LocPSQDq6dscope5ScopePSQEi4root5array__T5ArrayTCQFhQz10rootobject10RootObjectZQBmCQGp5mtype4TypePSQHfQCxQCv__TQCsTCQHw10expression10ExpressionZQDzPPxaZv
(pMessage=0x7fffffffaa40, fargs=0x7fffee6398e0, tthis=0x0, tiargs=0x0,
sc=0x7fffee5ca260, loc=..., dstart=0x7fffee43f3e0, m=0x7fffffffaa20) at
dmd/dtemplate.d:2799

Array<RootObject*>*, Type*, Array<Expression*>*, int) (loc=...,
sc=0x7fffee5ca260, s=0x7fffee43f3e0, tiargs=0x0, tthis=0x0,
fargs=0x7fffee6398e0, flags=0) at dmd/func.d:2575

(this=0x7fffffffb608, exp=0x7fffee639900) at dmd/expressionsem.d:3414

v=0x7fffffffb608) at dmd/expression.d:5612

(e=0x7fffee639900, sc=0x7fffee5ca260) at dmd/expressionsem.d:9367

Expression*) (sc=0x7fffee5ca260, e1=0x7ffff7f4a930, e2=0x0) at
dmd/expression.d:921

ExpressionSemanticVisitor::visit(DotTemplateInstanceExp*) (this=0x7fffffffb7c8,
exp=0x7ffff7f4a930) at dmd/expressionsem.d:4591

(this=0x7ffff7f4a930, v=0x7fffffffb7c8) at dmd/expression.d:5426

(e=0x7ffff7f4a930, sc=0x7fffee5ca260) at dmd/expressionsem.d:9367

(this=0x7fffffffb898, s=0x7ffff7f4aad0) at dmd/statementsem.d:178

v=0x7fffffffb898) at dmd/statement.d:715

(s=0x7ffff7f4aad0, sc=0x7fffee5ca260) at dmd/statementsem.d:127

(this=0x7fffffffbb98, cs=0x7ffff7f4bc70) at dmd/statementsem.d:236

(this=0x7ffff7f4bc70, v=0x7fffffffbb98) at dmd/statement.d:908

(s=0x7ffff7f4bc70, sc=0x7fffee5ca260) at dmd/statementsem.d:127

(this=0x7fffffffc510, funcdecl=0x7ffff7f4bc90) at dmd/semantic3.d:581

ParseTimeVisitor<ASTCodegen>::visit(UnitTestDeclaration*) (this=0x7fffffffc510,
s=0x7ffff7f4bc90) at dmd/parsetimevisitor.d:56

(this=0x7ffff7f4bc90, v=0x7fffffffc510) at dmd/func.d:3585

sc=0x7ffff4a5fa70) at dmd/semantic3.d:83

(this=0x7fffffffc5c0, mod=0x7ffff7e9eb80) at dmd/semantic3.d:196

v=0x7fffffffc5c0) at dmd/dmodule.d:1322

sc=0x0) at dmd/semantic3.d:83

(argv=0x7fffffffd4c8, argc=22) at dmd/mars.d:836

---

--
Apr 03 2018