www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20995] New: Range violation with -preview=dip1021

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

          Issue ID: 20995
           Summary: Range violation with -preview=dip1021
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: moonlightsentinel disroot.org

This code causes a range violation inside dmd:

======================================
void foo()  live
{
    throw new Exception("");
}

void main () {}
======================================

..\generated\windows\release\64\dmd.exe -c -o- -preview=dip1021 dip1021range.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.093.0-beta.1-9-g4de537b0c
predefs   DigitalMars Windows CRuntime_DigitalMars CppRuntime_DigitalMars
LittleEndian D_Version2 all D_InlineAsm D_InlineAsm_X86 X86 Win32 assert
D_ModuleInfo D_Exceptions D_TypeInfo D_HardFloat
binary    dmd\generated\windows\release\64\dmd.exe
version   v2.093.0-beta.1-9-g4de537b0c
config    dmd\generated\windows\release\64\sc.ini
DFLAGS    -Idmd\generated\windows\release\64\..\..\..\..\..\druntime\import
-Idmd\generated\windows\release\64\..\..\..\..\..\phobos
---

core.exception.RangeError dmd\escape.d(144): Range violation
----------------
0x00007FF7B0D54792 in d_arrayboundsp
0x00007FF7B0A0AEA9 in dmd.escape.checkMutableArguments at
dmd\src\dmd\escape.d(144)
0x00007FF7B0A36E1E in dmd.expressionsem.functionParameters at
dmd\src\dmd\expressionsem.d(2353)
0x00007FF7B0A43D93 in dmd.expressionsem.ExpressionSemanticVisitor.visit at
dmd\src\dmd\expressionsem.d(4995)
0x00007FF7B0A24BB2 in dmd.expression.CallExp.accept at
dmd\src\dmd\expression.d(4977)
0x00007FF7B0A633EF in dmd.expressionsem.expressionSemantic at
dmd\src\dmd\expressionsem.d(11478)
0x00007FF7B0B8415A in dmd.statementsem.StatementSemanticVisitor.visit at
dmd\src\dmd\statementsem.d(3160)
0x00007FF7B0B71F22 in dmd.statement.ReturnStatement.accept at
dmd\src\dmd\statement.d(1829)
0x00007FF7B0B74EAF in dmd.statementsem.statementSemantic at
dmd\src\dmd\statementsem.d(131)
0x00007FF7B0B7546C in dmd.statementsem.StatementSemanticVisitor.visit at
dmd\src\dmd\statementsem.d(244)
0x00007FF7B0B6F372 in dmd.statement.CompoundStatement.accept at
dmd\src\dmd\statement.d(938)
0x00007FF7B0B74EAF in dmd.statementsem.statementSemantic at
dmd\src\dmd\statementsem.d(131)
0x00007FF7B0B65911 in dmd.semantic3.Semantic3Visitor.visit at
dmd\src\dmd\semantic3.d(577)
0x00007FF7B0A705C2 in dmd.func.FuncDeclaration.accept at
dmd\src\dmd\func.d(2564)
0x00007FF7B0B63D01 in dmd.semantic3.semantic3 at dmd\src\dmd\semantic3.d(81)
0x00007FF7B0B6AC58 in dmd.semantic3.Semantic3Visitor.visit at
dmd\src\dmd\semantic3.d(1441)
0x00007FF7B0B5B6E2 in
dmd.parsetimevisitor.ParseTimeVisitor!(dmd.astcodegen.ASTCodegen).ParseTimeVisitor.visit
at dmd\src\dmd\parsetimevisitor.d(70)
0x00007FF7B090E892 in dmd.attrib.LinkDeclaration.accept at
dmd\src\dmd\attrib.d(416)
0x00007FF7B0B63D01 in dmd.semantic3.semantic3 at dmd\src\dmd\semantic3.d(81)
0x00007FF7B0B6415B in dmd.semantic3.Semantic3Visitor.visit at
dmd\src\dmd\semantic3.d(171)
0x00007FF7B09FD9F2 in dmd.dtemplate.TemplateMixin.accept at
dmd\src\dmd\dtemplate.d(7705)
0x00007FF7B0B63D01 in dmd.semantic3.semantic3 at dmd\src\dmd\semantic3.d(81)
0x00007FF7B0B6426C in dmd.semantic3.Semantic3Visitor.visit at
dmd\src\dmd\semantic3.d(194)
0x00007FF7B09978D2 in dmd.dmodule.Module.accept at dmd\src\dmd\dmodule.d(1462)
0x00007FF7B0B63D01 in dmd.semantic3.semantic3 at dmd\src\dmd\semantic3.d(81)
0x00007FF7B0AF74D6 in dmd.mars.tryMain at dmd\src\dmd\mars.d(597)
0x00007FF7B0AF9B20 in dmd.mars._Dmain at dmd\src\dmd\mars.d(952)
0x00007FF7B0D630D3 in void rt.dmain2._d_run_main2(char[][], ulong, extern (C)
int function(char[][])*).runAll().__lambda1()
0x00007FF7B0D62F0C in void rt.dmain2._d_run_main2(char[][], ulong, extern (C)
int function(char[][])*).tryExec(scope void delegate())
0x00007FF7B0D6300B in void rt.dmain2._d_run_main2(char[][], ulong, extern (C)
int function(char[][])*).runAll()
0x00007FF7B0D62F0C in void rt.dmain2._d_run_main2(char[][], ulong, extern (C)
int function(char[][])*).tryExec(scope void delegate())
0x00007FF7B0D62D43 in d_run_main2
0x00007FF7B0D5C700 in d_run_main
0x00007FF7B0AF9AA8 in dmd.mars.main at dmd\src\dmd\mars.d(911)
0x00007FF7B0DB2BCC in __scrt_common_main_seh at
d:\agent\_work\2\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl(288)
0x00007FF86B567BD4 in BaseThreadInitThunk
0x00007FF86D2ECE51 in RtlUserThreadStart


The range violation happens here:
https://github.com/dlang/dmd/blob/560fa54e97f1a9258afe037316ec8be87ea56e6c/src/dmd/escape.d#L143
i = 3, len = 3, outerVars.length = 0

--
Jun 30