www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20580] New: -preview=dip1021 compiler crash

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

          Issue ID: 20580
           Summary: -preview=dip1021 compiler crash
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: john.loughran.colvin gmail.com

% cat garbage.d
 safe:

template NodePtr(alias PtrTempl, T)
{
    struct NodeImpl
    {
        T val;
    }

    alias NodePtr = PtrTempl!NodeImpl;
}

struct SLL(NodePtrT)
{
    NodePtrT head;

    void insert(typeof(NodePtrT.val) t)
    {
        NodePtrT(t, head);
    }
}

alias DataStructure = SLL!(NodePtr!(UserCollected, int));

SLL!(NodePtr!(GarbageCollected, NodePtr!(UserCollected, int))) deadList;

struct GarbageCollected(T)
{
    T* obj;

    this(Args...)(Args )
    {
    }

    auto opDispatch(string mem)()  property
    {
        return __traits(getMember, obj, mem);
    }
}

struct UserCollected(T)
{
    int payload;
    void decRef()
    {
            if (payload)
                deadList.insert(this);
    }

    ~this()
    {
        decRef;
    }

    auto opDispatch(string mem)()  property
    {
        return payload;
    }
}



% dmd -preview=dip1021 garbage.d
---
ERROR: This is a compiler bug.
Please report it via https://issues.dlang.org/enter_bug.cgi
with, preferably, a reduced, reproducible example and the information below.
DustMite (https://github.com/CyberShadow/DustMite/wiki) can help with the
reduction.
---
DMD v2.090.1-170-gb76cfbc7b
predefs   DigitalMars Posix linux ELFv1 CRuntime_Glibc CppRuntime_Gcc
LittleEndian D_Version2 all D_SIMD D_InlineAsm_X86_64 X86_64 D_LP64 D_PIC
assert D_ModuleInfo D_Exceptions D_TypeInfo D_HardFloat
binary    /home/john/Git/dmd/generated/linux/release/64/dmd
version   v2.090.1-170-gb76cfbc7b
config    /home/john/Git/dmd/generated/linux/release/64/dmd.conf
DFLAGS   
-I/home/john/Git/dmd/generated/linux/release/64/../../../../../druntime/import
-I/home/john/Git/dmd/generated/linux/release/64/../../../../../phobos
-L-L/home/john/Git/dmd/generated/linux/release/64/../../../../../phobos/generated/linux/release/64
-L--export-dynamic -fPIC
---
core.exception.RangeError dmd/root/array.d(246): Range violation
----------------
??:? _d_arrayboundsp [0x7f38a58d2b71]
dmd/root/array.d:246 _ZN5ArrayIP10ExpressionEixEm [0x7f38a57282ba]
dmd/escape.d:211 bool dmd.escape.checkMutableArguments(dmd.dscope.Scope*,
dmd.func.FuncDeclaration, dmd.mtype.TypeFunction, dmd.expression.Expression,
dmd.root.array.Array!(dmd.expression.Expression).Array*, bool) [0x7f38a56bf80a]
dmd/expressionsem.d:2301 bool dmd.expressionsem.functionParameters(ref
const(dmd.globals.Loc), dmd.dscope.Scope*, dmd.mtype.TypeFunction,
dmd.expression.Expression, dmd.mtype.Type,
dmd.root.array.Array!(dmd.expression.Expression).Array*,
dmd.func.FuncDeclaration, dmd.mtype.Type*, dmd.expression.Expression*)
[0x7f38a56dc5c0]
dmd/expressionsem.d:4909 _ZN25ExpressionSemanticVisitor5visitEP7CallExp
[0x7f38a56e53a2]
dmd/expression.d:4948 _ZN7CallExp6acceptEP7Visitor [0x7f38a56d0361]
dmd/expressionsem.d:11263 _Z18expressionSemanticP10ExpressionP5Scope
[0x7f38a56f932f]
dmd/statementsem.d:177 _ZN24StatementSemanticVisitor5visitEP12ExpStatement
[0x7f38a57a6c11]
dmd/statement.d:749 _ZN12ExpStatement6acceptEP7Visitor [0x7f38a57a26f9]
dmd/statementsem.d:126 _Z17statementSemanticP9StatementP5Scope [0x7f38a57a6afb]
dmd/statementsem.d:235 _ZN24StatementSemanticVisitor5visitEP17CompoundStatement
[0x7f38a57a6ed3]
dmd/statement.d:937 _ZN17CompoundStatement6acceptEP7Visitor [0x7f38a57a2f75]
dmd/statementsem.d:126 _Z17statementSemanticP9StatementP5Scope [0x7f38a57a6afb]
dmd/statementsem.d:4361 dmd.statement.Statement
dmd.statementsem.semanticNoScope(dmd.statement.Statement, dmd.dscope.Scope*)
[0x7f38a57b5127]
dmd/statementsem.d:2261 _ZN24StatementSemanticVisitor5visitEP11IfStatement
[0x7f38a57ade7e]
dmd/statement.d:1403 _ZN11IfStatement6acceptEP7Visitor [0x7f38a57a3e45]
dmd/statementsem.d:126 _Z17statementSemanticP9StatementP5Scope [0x7f38a57a6afb]
dmd/statementsem.d:235 _ZN24StatementSemanticVisitor5visitEP17CompoundStatement
[0x7f38a57a6ed3]
dmd/statement.d:937 _ZN17CompoundStatement6acceptEP7Visitor [0x7f38a57a2f75]
dmd/statementsem.d:126 _Z17statementSemanticP9StatementP5Scope [0x7f38a57a6afb]
dmd/semantic3.d:585 _ZN16Semantic3Visitor5visitEP15FuncDeclaration
[0x7f38a579cbe1]
dmd/func.d:2511 _ZN15FuncDeclaration6acceptEP7Visitor [0x7f38a5701d55]
dmd/semantic3.d:82 _Z9semantic3P7DsymbolP5Scope [0x7f38a579b459]
dmd/func.d:436 _ZN15FuncDeclaration17functionSemantic3Ev [0x7f38a56fcc45]
dmd/func.d:410 _ZN15FuncDeclaration16functionSemanticEv [0x7f38a56fcb59]
dmd/expressionsem.d:916 dmd.expression.Expression
dmd.expressionsem.symbolToExp(dmd.dsymbol.Dsymbol, ref const(dmd.globals.Loc),
dmd.dscope.Scope*, bool) [0x7f38a56d8360]
dmd/expressionsem.d:2572 _ZN25ExpressionSemanticVisitor5visitEP13IdentifierExp
[0x7f38a56dd490]
dmd/expression.d:2103 _ZN13IdentifierExp6acceptEP7Visitor [0x7f38a56c9789]
dmd/expressionsem.d:11263 _Z18expressionSemanticP10ExpressionP5Scope
[0x7f38a56f932f]
dmd/statementsem.d:177 _ZN24StatementSemanticVisitor5visitEP12ExpStatement
[0x7f38a57a6c11]
dmd/statement.d:749 _ZN12ExpStatement6acceptEP7Visitor [0x7f38a57a26f9]
dmd/statementsem.d:126 _Z17statementSemanticP9StatementP5Scope [0x7f38a57a6afb]
dmd/statementsem.d:235 _ZN24StatementSemanticVisitor5visitEP17CompoundStatement
[0x7f38a57a6ed3]
dmd/statement.d:937 _ZN17CompoundStatement6acceptEP7Visitor [0x7f38a57a2f75]
dmd/statementsem.d:126 _Z17statementSemanticP9StatementP5Scope [0x7f38a57a6afb]
dmd/semantic3.d:585 _ZN16Semantic3Visitor5visitEP15FuncDeclaration
[0x7f38a579cbe1]
dmd/parsetimevisitor.d:54
_ZN16ParseTimeVisitorI10ASTCodegenE5visitEP15DtorDeclaration [0x7f38a5796891]
dmd/func.d:3591 _ZN15DtorDeclaration6acceptEP7Visitor [0x7f38a57042d1]
dmd/semantic3.d:82 _Z9semantic3P7DsymbolP5Scope [0x7f38a579b459]
dmd/func.d:436 _ZN15FuncDeclaration17functionSemantic3Ev [0x7f38a56fcc45]
dmd/func.d:410 _ZN15FuncDeclaration16functionSemanticEv [0x7f38a56fcb59]
dmd/clone.d:871 dmd.func.DtorDeclaration
dmd.clone.buildDtor(dmd.aggregate.AggregateDeclaration, dmd.dscope.Scope*)
[0x7f38a5629d29]
dmd/dsymbolsem.d:4690 _ZN22DsymbolSemanticVisitor5visitEP17StructDeclaration
[0x7f38a56a528a]
dmd/dstruct.d:603 _ZN17StructDeclaration6acceptEP7Visitor [0x7f38a56901c1]
dmd/dsymbolsem.d:564 _Z15dsymbolSemanticP7DsymbolP5Scope [0x7f38a569826d]
dmd/dtemplate.d:7286 void
dmd.dtemplate.TemplateInstance.expandMembers(dmd.dscope.Scope*).symbolDg(dmd.dsymbol.Dsymbol)
[0x7f38a56bc238]
dmd/dsymbol.d:99 void
dmd.dsymbol.foreachDsymbol(dmd.root.array.Array!(dmd.dsymbol.Dsymbol).Array*,
void delegate(dmd.dsymbol.Dsymbol)) [0x7f38a569073b]
dmd/dtemplate.d:7291 void
dmd.dtemplate.TemplateInstance.expandMembers(dmd.dscope.Scope*)
[0x7f38a56bc1c4]
dmd/dtemplate.d:7306 void
dmd.dtemplate.TemplateInstance.tryExpandMembers(dmd.dscope.Scope*)
[0x7f38a56bc2a2]
dmd/dsymbolsem.d:6066 void
dmd.dsymbolsem.templateInstanceSemantic(dmd.dtemplate.TemplateInstance,
dmd.dscope.Scope*, dmd.root.array.Array!(dmd.expression.Expression).Array*)
[0x7f38a56a970f]
dmd/dsymbolsem.d:2816 _ZN22DsymbolSemanticVisitor5visitEP16TemplateInstance
[0x7f38a569f772]
dmd/dtemplate.d:7335 _ZN16TemplateInstance6acceptEP7Visitor [0x7f38a56bc35d]
dmd/dsymbolsem.d:564 _Z15dsymbolSemanticP7DsymbolP5Scope [0x7f38a569826d]
dmd/typesem.d:2849 void dmd.typesem.resolve(dmd.mtype.Type, ref
const(dmd.globals.Loc), dmd.dscope.Scope*, dmd.expression.Expression*,
dmd.mtype.Type*, dmd.dsymbol.Dsymbol*,
bool).visitInstance(dmd.mtype.TypeInstance) [0x7f38a57ca896]
dmd/typesem.d:3099 void dmd.typesem.resolve(dmd.mtype.Type, ref
const(dmd.globals.Loc), dmd.dscope.Scope*, dmd.expression.Expression*,
dmd.mtype.Type*, dmd.dsymbol.Dsymbol*, bool) [0x7f38a57c9cb6]
dmd/mtype.d:5362 _ZN12TypeInstance9toDsymbolEP5Scope [0x7f38a5768517]
dmd/dsymbolsem.d:6386 void
dmd.dsymbolsem.aliasSemantic(dmd.declaration.AliasDeclaration,
dmd.dscope.Scope*) [0x7f38a56aa24b]
dmd/dsymbolsem.d:746 _ZN22DsymbolSemanticVisitor5visitEP16AliasDeclaration
[0x7f38a5698a75]
dmd/declaration.d:959 _ZN16AliasDeclaration6acceptEP7Visitor [0x7f38a5655441]
dmd/dsymbolsem.d:564 _Z15dsymbolSemanticP7DsymbolP5Scope [0x7f38a569826d]
dmd/dsymbolsem.d:1783
_ZN22DsymbolSemanticVisitor14attribSemanticEP17AttribDeclaration
[0x7f38a569c116]
dmd/dsymbolsem.d:1795 _ZN22DsymbolSemanticVisitor5visitEP17AttribDeclaration
[0x7f38a569c17c]
dmd/parsetimevisitor.d:73
_ZN16ParseTimeVisitorI10ASTCodegenE5visitEP23StorageClassDeclaration
[0x7f38a5796af2]
dmd/attrib.d:311 _ZN23StorageClassDeclaration6acceptEP7Visitor [0x7f38a5620d19]
dmd/dsymbolsem.d:564 _Z15dsymbolSemanticP7DsymbolP5Scope [0x7f38a569826d]
dmd/dsymbolsem.d:2246 void
dmd.dsymbolsem.DsymbolSemanticVisitor.visit(dmd.dmodule.Module).__lambda2!(dmd.dsymbol.Dsymbol).__lambda2(dmd.dsymbol.Dsymbol)
[0x7f38a569daec]
dmd/dsymbol.d:99 void
dmd.dsymbol.foreachDsymbol(dmd.root.array.Array!(dmd.dsymbol.Dsymbol).Array*,
void delegate(dmd.dsymbol.Dsymbol)) [0x7f38a569073b]
dmd/dsymbolsem.d:2243 _ZN22DsymbolSemanticVisitor5visitEP6Module
[0x7f38a569da7b]
dmd/dmodule.d:1455 _ZN6Module6acceptEP7Visitor [0x7f38a5678779]
dmd/dsymbolsem.d:564 _Z15dsymbolSemanticP7DsymbolP5Scope [0x7f38a569826d]
dmd/mars.d:565 int dmd.mars.tryMain(ulong, const(char)**, ref
dmd.globals.Param) [0x7f38a5755c3c]

--
Feb 13 2020