[Issue 21595] New: DMD crashes with -preview=dip1021 and std.string.indexOf

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jan 30 17:46:33 UTC 2021


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

          Issue ID: 21595
           Summary: DMD crashes with -preview=dip1021 and
                    std.string.indexOf
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: dlang at ryanjframe.com

With the code:

---
void main() {
    import std.string : indexOf;
    "a".indexOf('a');
}
---

Compiled via `dmd -preview=dip1021 code.d`

The compiler will crash. I've reproduced this with every dmd version I've
checked against:
- head
- 2.095.0
- 2.094.2
- 2.093.0
- 2.090.0
- 2.089.1 (the flag was introduced in 2.089)

It only crashes if searching for a character -- a string parameter is fine.


Compiler output:

DMD v2.095.0-136-gb48327458
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    ./dmd
version   v2.095.0-136-gb48327458
config    dmd.conf
DFLAGS    -I./../../../../../druntime/import -I./../../../../../phobos
-L-L./../../../../../phobos/generated/linux/release/64 -L--export-dynamic -fPIC
---
core.exception.AssertError at src/dmd/escape.d(1865): Assertion failure
----------------
??:? _d_assertp [0x130a5922ab1]
src/dmd/escape.d:1865 _ZN11escapeByRef16EscapeRefVisitor5visitEP6VarExp
[0x130a570da2f]
src/dmd/expression.d:3741 _ZN6VarExp6acceptEP7Visitor [0x130a57172f5]
src/dmd/escape.d:2054 void dmd.escape.escapeByRef(dmd.expression.Expression,
dmd.escape.EscapeByResults*, bool) [0x130a570d948]
src/dmd/escape.d:152 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) [0x130a5708f17]
src/dmd/expressionsem.d:2443 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*)
[0x130a57274a2]
src/dmd/expressionsem.d:5107 _ZN25ExpressionSemanticVisitor5visitEP7CallExp
[0x130a5730517]
src/dmd/expression.d:5126 _ZN7CallExp6acceptEP7Visitor [0x130a571a979]
src/dmd/expressionsem.d:11670 _Z18expressionSemanticP10ExpressionP5Scope
[0x130a5744de7]
src/dmd/opover.d:508 _ZN11op_overload10OpOverload5visitEP8ArrayExp
[0x130a578f79c]
src/dmd/expression.d:5587 _ZN8ArrayExp6acceptEP7Visitor [0x130a571b92d]
src/dmd/opover.d:1321 dmd.expression.Expression
dmd.opover.op_overload(dmd.expression.Expression, dmd.dscope.Scope*,
dmd.tokens.TOK*) [0x130a578ea37]
src/dmd/expressionsem.d:7844 _ZN25ExpressionSemanticVisitor5visitEP8ArrayExp
[0x130a5739395]
src/dmd/expression.d:5587 _ZN8ArrayExp6acceptEP7Visitor [0x130a571b92d]
src/dmd/expressionsem.d:11670 _Z18expressionSemanticP10ExpressionP5Scope
[0x130a5744de7]
src/dmd/typesem.d:2903 void dmd.typesem.resolve(dmd.mtype.Type, ref
const(dmd.globals.Loc), dmd.dscope.Scope*, out dmd.expression.Expression, out
dmd.mtype.Type, out dmd.dsymbol.Dsymbol,
bool).visitTypeof(dmd.mtype.TypeTypeof) [0x130a57e4fb9]
src/dmd/typesem.d:3130 void dmd.typesem.resolve(dmd.mtype.Type, ref
const(dmd.globals.Loc), dmd.dscope.Scope*, out dmd.expression.Expression, out
dmd.mtype.Type, out dmd.dsymbol.Dsymbol, bool) [0x130a57e42b4]
src/dmd/typesem.d:1739 dmd.mtype.Type dmd.typesem.typeSemantic(dmd.mtype.Type,
ref const(dmd.globals.Loc),
dmd.dscope.Scope*).visitTypeof(dmd.mtype.TypeTypeof) [0x130a57e1cbf]
src/dmd/typesem.d:2001 _Z12typeSemanticP4TypeRK3LocP5Scope [0x130a57de945]
src/dmd/mtype.d:945 _ZN4Type11trySemanticERK3LocP5Scope [0x130a57757d6]
src/dmd/expressionsem.d:5506 _ZN25ExpressionSemanticVisitor5visitEP5IsExp
[0x130a5731997]
src/dmd/expression.d:4213 _ZN5IsExp6acceptEP7Visitor [0x130a571863d]
src/dmd/expressionsem.d:11670 _Z18expressionSemanticP10ExpressionP5Scope
[0x130a5744de7]
src/dmd/expressionsem.d:10882
_ZN25ExpressionSemanticVisitor5visitEP10LogicalExp [0x130a5742aae]
src/dmd/expression.d:6510 _ZN10LogicalExp6acceptEP7Visitor [0x130a571d315]
src/dmd/expressionsem.d:11670 _Z18expressionSemanticP10ExpressionP5Scope
[0x130a5744de7]
src/dmd/expressionsem.d:10882
_ZN25ExpressionSemanticVisitor5visitEP10LogicalExp [0x130a5742aae]
src/dmd/expression.d:6510 _ZN10LogicalExp6acceptEP7Visitor [0x130a571d315]
src/dmd/expressionsem.d:11670 _Z18expressionSemanticP10ExpressionP5Scope
[0x130a5744de7]
src/dmd/expressionsem.d:10882
_ZN25ExpressionSemanticVisitor5visitEP10LogicalExp [0x130a5742aae]
src/dmd/expression.d:6510 _ZN10LogicalExp6acceptEP7Visitor [0x130a571d315]
src/dmd/expressionsem.d:11670 _Z18expressionSemanticP10ExpressionP5Scope
[0x130a5744de7]
src/dmd/expressionsem.d:10882
_ZN25ExpressionSemanticVisitor5visitEP10LogicalExp [0x130a5742aae]
src/dmd/expression.d:6510 _ZN10LogicalExp6acceptEP7Visitor [0x130a571d315]
src/dmd/expressionsem.d:11670 _Z18expressionSemanticP10ExpressionP5Scope
[0x130a5744de7]
src/dmd/expressionsem.d:10882
_ZN25ExpressionSemanticVisitor5visitEP10LogicalExp [0x130a5742aae]
src/dmd/expression.d:6510 _ZN10LogicalExp6acceptEP7Visitor [0x130a571d315]
src/dmd/expressionsem.d:11670 _Z18expressionSemanticP10ExpressionP5Scope
[0x130a5744de7]
src/dmd/dsymbolsem.d:1496 _ZN22DsymbolSemanticVisitor5visitEP14VarDeclaration
[0x130a56a9d14]
src/dmd/declaration.d:1633 _ZN14VarDeclaration6acceptEP7Visitor [0x130a5664da1]
src/dmd/dsymbolsem.d:581 _Z15dsymbolSemanticP7DsymbolP5Scope [0x130a56a6efd]
src/dmd/dtemplate.d:7402 void
dmd.dtemplate.TemplateInstance.expandMembers(dmd.dscope.Scope*).symbolDg(dmd.dsymbol.Dsymbol)
[0x130a56cca98]
src/dmd/dsymbol.d:103 void
dmd.dsymbol.foreachDsymbol(dmd.root.array.Array!(dmd.dsymbol.Dsymbol).Array*,
void delegate(dmd.dsymbol.Dsymbol)) [0x130a569edfb]
src/dmd/dtemplate.d:7407 void
dmd.dtemplate.TemplateInstance.expandMembers(dmd.dscope.Scope*) [0x130a56cca25]
src/dmd/dtemplate.d:7422 void
dmd.dtemplate.TemplateInstance.tryExpandMembers(dmd.dscope.Scope*)
[0x130a56ccb02]
src/dmd/dsymbolsem.d:6261 void
dmd.dsymbolsem.templateInstanceSemantic(dmd.dtemplate.TemplateInstance,
dmd.dscope.Scope*, dmd.root.array.Array!(dmd.expression.Expression).Array*)
[0x130a56b8b4c]
src/dmd/dsymbolsem.d:2870 _ZN22DsymbolSemanticVisitor5visitEP16TemplateInstance
[0x130a56ae6d6]
src/dmd/dtemplate.d:7451 _ZN16TemplateInstance6acceptEP7Visitor [0x130a56ccbbd]
src/dmd/dsymbolsem.d:581 _Z15dsymbolSemanticP7DsymbolP5Scope [0x130a56a6efd]
src/dmd/expressionsem.d:3362 _ZN25ExpressionSemanticVisitor5visitEP8ScopeExp
[0x130a572a086]
src/dmd/expression.d:3471 _ZN8ScopeExp6acceptEP7Visitor [0x130a5716955]
src/dmd/expressionsem.d:11670 _Z18expressionSemanticP10ExpressionP5Scope
[0x130a5744de7]
src/dmd/staticcond.d:94 bool
dmd.staticcond.evalStaticCondition(dmd.dscope.Scope*,
dmd.expression.Expression, dmd.expression.Expression, out bool,
dmd.root.array.Array!(dmd.expression.Expression).Array*).impl(dmd.expression.Expression)
[0x130a57d09a4]
src/dmd/staticcond.d:124 bool
dmd.staticcond.evalStaticCondition(dmd.dscope.Scope*,
dmd.expression.Expression, dmd.expression.Expression, out bool,
dmd.root.array.Array!(dmd.expression.Expression).Array*) [0x130a57d07f7]
src/dmd/semantic2.d:102 _ZN16Semantic2Visitor5visitEP12StaticAssert
[0x130a57b1a14]
src/dmd/staticassert.d:64 _ZN12StaticAssert6acceptEP7Visitor [0x130a57d07aa]
src/dmd/semantic2.d:78 _Z9semantic2P7DsymbolP5Scope [0x130a57b1941]
src/dmd/statementsem.d:2503
_ZN24StatementSemanticVisitor5visitEP21StaticAssertStatement [0x130a57c6f87]
src/dmd/statement.d:1625 _ZN21StaticAssertStatement6acceptEP7Visitor
[0x130a57bc9a9]
src/dmd/statementsem.d:137 _Z17statementSemanticP9StatementP5Scope
[0x130a57bf0cf]
src/dmd/statementsem.d:250
_ZN24StatementSemanticVisitor5visitEP17CompoundStatement [0x130a57bf46f]
src/dmd/statement.d:967 _ZN17CompoundStatement6acceptEP7Visitor [0x130a57bb435]
src/dmd/statementsem.d:137 _Z17statementSemanticP9StatementP5Scope
[0x130a57bf0cf]
src/dmd/semantic3.d:582 _ZN16Semantic3Visitor5visitEP15FuncDeclaration
[0x130a57b4bb5]
src/dmd/func.d:2634 _ZN15FuncDeclaration6acceptEP7Visitor [0x130a574e0a9]
src/dmd/semantic3.d:81 _Z9semantic3P7DsymbolP5Scope [0x130a57b3639]
src/dmd/semantic3.d:131 _ZN16Semantic3Visitor5visitEP16TemplateInstance
[0x130a57b37ed]
src/dmd/dtemplate.d:7451 _ZN16TemplateInstance6acceptEP7Visitor [0x130a56ccbbd]
src/dmd/semantic3.d:81 _Z9semantic3P7DsymbolP5Scope [0x130a57b3639]
src/dmd/dtemplate.d:7439 void
dmd.dtemplate.TemplateInstance.trySemantic3(dmd.dscope.Scope*) [0x130a56ccb76]
src/dmd/dsymbolsem.d:6399 void
dmd.dsymbolsem.templateInstanceSemantic(dmd.dtemplate.TemplateInstance,
dmd.dscope.Scope*, dmd.root.array.Array!(dmd.expression.Expression).Array*)
[0x130a56b901f]
src/dmd/dtemplate.d:3076 void dmd.dtemplate.functionResolve(ref
dmd.declaration.MatchAccumulator, dmd.dsymbol.Dsymbol, dmd.globals.Loc,
dmd.dscope.Scope*,
dmd.root.array.Array!(dmd.root.rootobject.RootObject).Array*, dmd.mtype.Type,
dmd.root.array.Array!(dmd.expression.Expression).Array*, const(char)**)
[0x130a56c0ac2]
src/dmd/func.d:2929 dmd.func.FuncDeclaration dmd.func.resolveFuncCall(ref
const(dmd.globals.Loc), dmd.dscope.Scope*, dmd.dsymbol.Dsymbol,
dmd.root.array.Array!(dmd.root.rootobject.RootObject).Array*, dmd.mtype.Type,
dmd.root.array.Array!(dmd.expression.Expression).Array*,
dmd.func.FuncResolveFlag) [0x130a574e8ae]
src/dmd/expressionsem.d:4943 _ZN25ExpressionSemanticVisitor5visitEP7CallExp
[0x130a572f6ef]
src/dmd/expression.d:5126 _ZN7CallExp6acceptEP7Visitor [0x130a571a979]
src/dmd/expressionsem.d:11670 _Z18expressionSemanticP10ExpressionP5Scope
[0x130a5744de7]
src/dmd/expressionsem.d:344 bool
dmd.expressionsem.arrayExpressionSemantic(dmd.root.array.Array!(dmd.expression.Expression).Array*,
dmd.dscope.Scope*, bool) [0x130a5721216]
src/dmd/expressionsem.d:4474 _ZN25ExpressionSemanticVisitor5visitEP7CallExp
[0x130a572dc99]
src/dmd/expression.d:5126 _ZN7CallExp6acceptEP7Visitor [0x130a571a979]
src/dmd/expressionsem.d:11670 _Z18expressionSemanticP10ExpressionP5Scope
[0x130a5744de7]
src/dmd/statementsem.d:3191
_ZN24StatementSemanticVisitor5visitEP15ReturnStatement [0x130a57c9758]
src/dmd/statement.d:1893 _ZN15ReturnStatement6acceptEP7Visitor [0x130a57bd1f1]
src/dmd/statementsem.d:137 _Z17statementSemanticP9StatementP5Scope
[0x130a57bf0cf]
src/dmd/statementsem.d:250
_ZN24StatementSemanticVisitor5visitEP17CompoundStatement [0x130a57bf46f]
src/dmd/statement.d:967 _ZN17CompoundStatement6acceptEP7Visitor [0x130a57bb435]
src/dmd/statementsem.d:137 _Z17statementSemanticP9StatementP5Scope
[0x130a57bf0cf]
src/dmd/semantic3.d:582 _ZN16Semantic3Visitor5visitEP15FuncDeclaration
[0x130a57b4bb5]
src/dmd/func.d:2634 _ZN15FuncDeclaration6acceptEP7Visitor [0x130a574e0a9]
src/dmd/semantic3.d:81 _Z9semantic3P7DsymbolP5Scope [0x130a57b3639]
src/dmd/semantic3.d:131 _ZN16Semantic3Visitor5visitEP16TemplateInstance
[0x130a57b37ed]
src/dmd/dtemplate.d:7451 _ZN16TemplateInstance6acceptEP7Visitor [0x130a56ccbbd]
src/dmd/semantic3.d:81 _Z9semantic3P7DsymbolP5Scope [0x130a57b3639]
src/dmd/dtemplate.d:7439 void
dmd.dtemplate.TemplateInstance.trySemantic3(dmd.dscope.Scope*) [0x130a56ccb76]
src/dmd/dsymbolsem.d:6399 void
dmd.dsymbolsem.templateInstanceSemantic(dmd.dtemplate.TemplateInstance,
dmd.dscope.Scope*, dmd.root.array.Array!(dmd.expression.Expression).Array*)
[0x130a56b901f]
src/dmd/dtemplate.d:3076 void dmd.dtemplate.functionResolve(ref
dmd.declaration.MatchAccumulator, dmd.dsymbol.Dsymbol, dmd.globals.Loc,
dmd.dscope.Scope*,
dmd.root.array.Array!(dmd.root.rootobject.RootObject).Array*, dmd.mtype.Type,
dmd.root.array.Array!(dmd.expression.Expression).Array*, const(char)**)
[0x130a56c0ac2]
src/dmd/func.d:2929 dmd.func.FuncDeclaration dmd.func.resolveFuncCall(ref
const(dmd.globals.Loc), dmd.dscope.Scope*, dmd.dsymbol.Dsymbol,
dmd.root.array.Array!(dmd.root.rootobject.RootObject).Array*, dmd.mtype.Type,
dmd.root.array.Array!(dmd.expression.Expression).Array*,
dmd.func.FuncResolveFlag) [0x130a574e8ae]
src/dmd/expressionsem.d:4943 _ZN25ExpressionSemanticVisitor5visitEP7CallExp
[0x130a572f6ef]
src/dmd/expression.d:5126 _ZN7CallExp6acceptEP7Visitor [0x130a571a979]
src/dmd/expressionsem.d:11670 _Z18expressionSemanticP10ExpressionP5Scope
[0x130a5744de7]
src/dmd/statementsem.d:1093
_ZN24StatementSemanticVisitor5visitEP16ForeachStatement [0x130a57c0943]
src/dmd/statement.d:1350 _ZN16ForeachStatement6acceptEP7Visitor [0x130a57bc059]
src/dmd/statementsem.d:137 _Z17statementSemanticP9StatementP5Scope
[0x130a57bf0cf]
src/dmd/statementsem.d:250
_ZN24StatementSemanticVisitor5visitEP17CompoundStatement [0x130a57bf46f]
src/dmd/statement.d:967 _ZN17CompoundStatement6acceptEP7Visitor [0x130a57bb435]
src/dmd/statementsem.d:137 _Z17statementSemanticP9StatementP5Scope
[0x130a57bf0cf]
src/dmd/statementsem.d:457
_ZN24StatementSemanticVisitor5visitEP14ScopeStatement [0x130a57c0025]
src/dmd/statement.d:1075 _ZN14ScopeStatement6acceptEP7Visitor [0x130a57bb83d]
src/dmd/statementsem.d:137 _Z17statementSemanticP9StatementP5Scope
[0x130a57bf0cf]
src/dmd/statementsem.d:4388 dmd.statement.Statement
dmd.statementsem.semanticNoScope(dmd.statement.Statement, dmd.dscope.Scope*)
[0x130a57cd91f]
src/dmd/statementsem.d:4402 dmd.statement.Statement
dmd.statementsem.semanticScope(dmd.statement.Statement, dmd.dscope.Scope*,
dmd.statement.Statement, dmd.statement.Statement) [0x130a57cd9b1]
src/dmd/statementsem.d:2293 _ZN24StatementSemanticVisitor5visitEP11IfStatement
[0x130a57c665b]
src/dmd/statement.d:1434 _ZN11IfStatement6acceptEP7Visitor [0x130a57bc33d]
src/dmd/statementsem.d:137 _Z17statementSemanticP9StatementP5Scope
[0x130a57bf0cf]
src/dmd/statementsem.d:250
_ZN24StatementSemanticVisitor5visitEP17CompoundStatement [0x130a57bf46f]
src/dmd/statement.d:967 _ZN17CompoundStatement6acceptEP7Visitor [0x130a57bb435]
src/dmd/statementsem.d:137 _Z17statementSemanticP9StatementP5Scope
[0x130a57bf0cf]
src/dmd/statementsem.d:457
_ZN24StatementSemanticVisitor5visitEP14ScopeStatement [0x130a57c0025]
src/dmd/statement.d:1075 _ZN14ScopeStatement6acceptEP7Visitor [0x130a57bb83d]
src/dmd/statementsem.d:137 _Z17statementSemanticP9StatementP5Scope
[0x130a57bf0cf]
src/dmd/statementsem.d:4388 dmd.statement.Statement
dmd.statementsem.semanticNoScope(dmd.statement.Statement, dmd.dscope.Scope*)
[0x130a57cd91f]
src/dmd/statementsem.d:2287 _ZN24StatementSemanticVisitor5visitEP11IfStatement
[0x130a57c65e6]
src/dmd/statement.d:1434 _ZN11IfStatement6acceptEP7Visitor [0x130a57bc33d]
src/dmd/statementsem.d:137 _Z17statementSemanticP9StatementP5Scope
[0x130a57bf0cf]

--


More information about the Digitalmars-d-bugs mailing list