www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24209] New: static aa initialization of static function

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

          Issue ID: 24209
           Summary: static aa initialization of static function variable
                    ICE
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: ice, ice-on-valid-code
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: schveiguy gmail.com
                CC: dkorpel live.nl

This crashes in master:

unittest {
   static int[int] aa = [1: 2];
}

Full output from the compiler (note line 164 of newaa.d is where I added this
line):

```
src/core/internal/newaa.d(164): Error: internal compiler error: failed to
detect static initialization of associative array
---
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.105.2-311-ga8fa992a73-dirty
predefs   Shared CoreUnittest DigitalMars LittleEndian D_Version2 all D_SIMD
Posix ELFv1 linux CRuntime_Glibc CppRuntime_Gcc D_InlineAsm_X86_64 X86_64
D_LP64 D_PIC unittest assert D_PreConditions D_PostConditions D_Invariants
D_ModuleInfo D_Exceptions D_TypeInfo D_HardFloat
binary    ../compiler/../generated/linux/release/64/dmd
version   v2.105.2-311-ga8fa992a73-dirty
config    
DFLAGS    (none)
---
core.exception.AssertError src/dmd/todt.d(491): Assertion failure
----------------
??:? _d_assertp [0x56181e2927d4]
src/dmd/todt.d:491 void dmd.todt.Expression_toDt(dmd.expression.Expression, ref
dmd.backend.dt.DtBuilder).visitAssocArrayLiteral(dmd.expression.AssocArrayLiteralExp)
[0x56181e15e9b9]
src/dmd/todt.d:637 _Z15Expression_toDtP10ExpressionR9DtBuilder [0x56181e15deb2]
src/dmd/todt.d:198 void dmd.todt.Initializer_toDt(dmd.init.Initializer, ref
dmd.backend.dt.DtBuilder, bool).visitExp(dmd.init.ExpInitializer)
[0x56181e15db42]
src/dmd/init.d:357 void dmd.todt.Initializer_toDt(dmd.init.Initializer, ref
dmd.backend.dt.DtBuilder, bool).visit.VisitInitializer(dmd.init.Initializer)
[0x56181e15dc2e]
src/dmd/todt.d:209 _Z16Initializer_toDtP11InitializerR9DtBuilderb
[0x56181e15d432]
src/dmd/toobj.d:874
_ZN9toObjFile9ToObjFile15initializerToDtEP14VarDeclarationR9DtBuilderb
[0x56181e166c19]
src/dmd/toobj.d:632 _ZN9toObjFile9ToObjFile5visitEP14VarDeclaration
[0x56181e16634f]
src/dmd/declaration.d:1741 _ZN14VarDeclaration6acceptEP7Visitor
[0x56181dfa26f1]
src/dmd/toobj.d:1017 _Z9toObjFileP7Dsymbolb [0x56181e16562c]
src/dmd/e2ir.d:4207 _Z14Dsymbol_toElemP7DsymbolR7IRState [0x56181e135700]
src/dmd/e2ir.d:792 dmd.backend.el.elem*
dmd.e2ir.toElem(dmd.expression.Expression, ref
dmd.toir.IRState).visitDeclaration(dmd.expression.DeclarationExp)
[0x56181e12b028]
src/dmd/e2ir.d:4157 _Z6toElemP10ExpressionR7IRState [0x56181e129d83]
src/dmd/e2ir.d:407 _Z10toElemDtorP10ExpressionR7IRState [0x56181e129405]
src/dmd/s2ir.d:690 void dmd.s2ir.Statement_toIR(dmd.statement.Statement, ref
dmd.toir.IRState,
dmd.stmtstate.StmtState!(dmd.backend.cc.block).StmtState*).visitExp(dmd.statement.ExpStatement)
[0x56181e15460c]
src/dmd/statement.d:1888 void dmd.s2ir.Statement_toIR(dmd.statement.Statement,
ref dmd.toir.IRState,
dmd.stmtstate.StmtState!(dmd.backend.cc.block).StmtState*).visit.VisitStatement(dmd.statement.Statement)
[0x56181e156bfb]
src/dmd/s2ir.d:1467 _Z14Statement_toIRP9StatementR7IRStateP9StmtStateI5blockE
[0x56181e152b9b]
src/dmd/s2ir.d:717 void dmd.s2ir.Statement_toIR(dmd.statement.Statement, ref
dmd.toir.IRState,
dmd.stmtstate.StmtState!(dmd.backend.cc.block).StmtState*).visitCompound(dmd.statement.CompoundStatement)
[0x56181e1546e7]
src/dmd/statement.d:1888 void dmd.s2ir.Statement_toIR(dmd.statement.Statement,
ref dmd.toir.IRState,
dmd.stmtstate.StmtState!(dmd.backend.cc.block).StmtState*).visit.VisitStatement(dmd.statement.Statement)
[0x56181e156c20]
src/dmd/s2ir.d:1467 _Z14Statement_toIRP9StatementR7IRStateP9StmtStateI5blockE
[0x56181e152b9b]
src/dmd/s2ir.d:717 void dmd.s2ir.Statement_toIR(dmd.statement.Statement, ref
dmd.toir.IRState,
dmd.stmtstate.StmtState!(dmd.backend.cc.block).StmtState*).visitCompound(dmd.statement.CompoundStatement)
[0x56181e1546e7]
src/dmd/statement.d:1888 void dmd.s2ir.Statement_toIR(dmd.statement.Statement,
ref dmd.toir.IRState,
dmd.stmtstate.StmtState!(dmd.backend.cc.block).StmtState*).visit.VisitStatement(dmd.statement.Statement)
[0x56181e156c20]
src/dmd/s2ir.d:1467 _Z14Statement_toIRP9StatementR7IRStateP9StmtStateI5blockE
[0x56181e152b9b]
src/dmd/s2ir.d:95 _Z14Statement_toIRP9StatementR7IRState [0x56181e152b79]
src/dmd/glue.d:1166 _Z25FuncDeclaration_toObjFileP15FuncDeclarationb
[0x56181e14bca0]
src/dmd/toobj.d:305 _ZN9toObjFile9ToObjFile5visitEP15FuncDeclaration
[0x56181e1656c5]
src/dmd/parsetimevisitor.d:61
_ZN16ParseTimeVisitorI10ASTCodegenE5visitEP19UnitTestDeclaration
[0x56181e0d6cbd]
src/dmd/func.d:4457 _ZN19UnitTestDeclaration6acceptEP7Visitor [0x56181e070315]
src/dmd/toobj.d:752 _ZN9toObjFile9ToObjFile5visitEP17AttribDeclaration
[0x56181e166782]
src/dmd/parsetimevisitor.d:79
_ZN16ParseTimeVisitorI10ASTCodegenE5visitEP22ConditionalDeclaration
[0x56181e0d6efa]
src/dmd/attrib.d:994 _ZN22ConditionalDeclaration6acceptEP7Visitor
[0x56181df6636d]
src/dmd/toobj.d:1017 _Z9toObjFileP7Dsymbolb [0x56181e16562c]
src/dmd/glue.d:578 _Z10genObjFileP6Moduleb [0x56181e14a03b]
src/dmd/glue.d:147 void dmd.glue.generateCodeAndWrite(dmd.dmodule.Module[],
const(char)*[], const(char)[], const(char)[], bool, bool, bool, bool, bool)
[0x56181e1485bb]
src/dmd/main.d:623 int dmd.main.tryMain(ulong, const(char)**, ref
dmd.globals.Param) [0x56181df56ee4]
src/dmd/main.d:133 _Dmain [0x56181df557e0]
```

--
Oct 29 2023