www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21025] New: Segfault for function contract -preview=dip1021

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

          Issue ID: 21025
           Summary: Segfault for function contract -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

The following code causes a segfault in DMD when compiled with
-preview=dip1021:

==================================
void uniq()(int[] r)
if (binaryFun(r, r)) {}

bool binaryFun(T, U)(T, U)
{
    return true;
}

void generateStatements()
{
    uniq([]);
}
==================================

gdb $DMD -batch -ex "run -c -o- -preview=dip1021" -ex bt

Program received signal SIGSEGV, Segmentation fault.
0x00000000083b93f4 in dmd.func.FuncDeclaration.setUnsafe() (this=0x0) at
dmd/func.d:1402
1402            if (flags & FUNCFLAG.safetyInprocess)


dmd/func.d:1402

_D3dmd6escape21checkMutableArgumentsFPSQBl6dscope5ScopeCQCc4func15FuncDeclarationCQDc5mtype12TypeFunctionCQEa10expression10ExpressionPSQFd4root5array__T5ArrayTQCcZQlbZ12checkOnePairMFmKSQHcQHbQGxFQGdQFoQErQDwQCxbZ8EscapeByKQBmCQIr11declaration14VarDeclarationQBhbZv
(__capture=0x7ffffffe9eb0, of=true, v2=0x7ffffdfb34c0, v=0x7ffffdfb34c0,
eb2=..., eb=..., i=0) at dmd/escape.d:167

_D3dmd6escape21checkMutableArgumentsFPSQBl6dscope5ScopeCQCc4func15FuncDeclarationCQDc5mtype12TypeFunctionCQEa10expression10ExpressionPSQFd4root5array__T5ArrayTQCcZQlbZQGfMFmKSQGrQGqQGmFQFsQFdQEgQDlQCmbZ8EscapeBybZv
(__capture=0x7ffffffe9eb0, byval=true, eb=..., i=0) at dmd/escape.d:203

_D3dmd6escape21checkMutableArgumentsFPSQBl6dscope5ScopeCQCc4func15FuncDeclarationCQDc5mtype12TypeFunctionCQEa10expression10ExpressionPSQFd4root5array__T5ArrayTQCcZQlbZb
(gag=false, arguments=0x7ffffdfb3690, ethis=0x0, tf=0x8c2fa50,
fd=0x7ffffdfb4670, sc=0x7ffffdfb0930) at dmd/escape.d:210

_D3dmd13expressionsem18functionParametersFKxSQBr7globals3LocPSQCi6dscope5ScopeCQCz5mtype12TypeFunctionCQDx10expression10ExpressionCQEzQCa4TypePSQFm4root5array__T5ArrayTQCoZQlCQGr4func15FuncDeclarationPQCtPQDzZb
(peprefix=0x7ffffffeab70, prettype=0x7ffffdfb3610, fd=0x7ffffdfb4670,
arguments=0x7ffffdfb3690, tthis=0x0, ethis=0x0, tf=0x8c2fa50,
sc=0x7ffffdfb0930, loc=...) at dmd/expressionsem.d:2354

(this=0x7ffffffeacf8, exp=0x7ffffdfb3600) at dmd/expressionsem.d:4999

v=0x7ffffffeacf8) at dmd/expression.d:4975

(e=0x7ffffdfb3600, sc=0x7ffffdfb0930) at dmd/expressionsem.d:11497

_D3dmd10staticcond19evalStaticConditionFPSQBo6dscope5ScopeCQCf10expression10ExpressionQBcJbPSQDn4root5array__T5ArrayTQChZQlZ4implMFQCvZb
(__capture=0x7ffffffeadd0, e=0x7ffffdfb3600) at dmd/staticcond.d:94

_D3dmd10staticcond19evalStaticConditionFPSQBo6dscope5ScopeCQCf10expression10ExpressionQBcJbPSQDn4root5array__T5ArrayTQChZQlZb
(negatives=0x7fffff6c6790, errors= 0x7ffffffeaea8: false, e=0x7ffffdfb3600,
original=0x7fffff6c6510, sc=0x7ffffdfb0930) at dmd/staticcond.d:124

_D3dmd9dtemplate19TemplateDeclaration18evaluateConstraintMFCQCgQCf16TemplateInstancePSQDg6dscope5ScopeQsPSQEa4root5array__T5ArrayTCQEzQz10rootobject10RootObjectZQBmCQGh4func15FuncDeclarationZb
(this=0x7fffff6c6660, fd=0x7ffffdfb3110, dedargs=0x7ffffdfb3000,
paramscope=0x7ffffdfb0620, sc=0x7ffffdfb0500, ti=0x7ffffdfb2e80) at
dmd/dtemplate.d:903

_D3dmd9dtemplate19TemplateDeclaration27deduceFunctionTemplateMatchMFCQCpQCo16TemplateInstancePSQDp6dscope5ScopeKCQEh4func15FuncDeclarationCQFh5mtype4TypePSQFx4root5array__T5ArrayTCQGw10expression10ExpressionZQBkZEQId7globals5MATCH
(this=0x7fffff6c6660, fargs=0x7fffff6c7540, tthis=0x0, fd= 0x7ffffffeb730:
0x7ffffdfb3110, sc=0x7ffffdfb0500, ti=0x7ffffdfb2e80) at dmd/dtemplate.d:2241

_D3dmd9dtemplate15functionResolveFKSQBi11declaration16MatchAccumulatorCQCr7dsymbol7DsymbolSQDl7globals3LocPSQEc6dscope5ScopePSQEu4root5array__T5ArrayTCQFtQz10rootobject10RootObjectZQBmCQHb5mtype4TypePSQHrQCxQCv__TQCsTCQIi10expression10ExpressionZQDzPPxaZ13applyTemplateMFCQKkQKj19TemplateDeclarationZi
(__capture=0x7ffffffeb940, td=0x7fffff6c6660) at dmd/dtemplate.d:2967

_D3dmd9dtemplate15functionResolveFKSQBi11declaration16MatchAccumulatorCQCr7dsymbol7DsymbolSQDl7globals3LocPSQEc6dscope5ScopePSQEu4root5array__T5ArrayTCQFtQz10rootobject10RootObjectZQBmCQHb5mtype4TypePSQHrQCxQCv__TQCsTCQIi10expression10ExpressionZQDzPPxaZ10__lambda11MFQHqZi
(__capture=0x7ffffffeb940, s=0x7fffff6c6660) at dmd/dtemplate.d:3074

_D3dmd4func13overloadApplyFCQBa7dsymbol7DsymbolMDFQxZiPSQCc6dscope5ScopeZi
(sc=0x7ffffdfb0500, dg=..., fstart=0x7fffff6c6660) at dmd/func.d:2696

_D3dmd9dtemplate15functionResolveFKSQBi11declaration16MatchAccumulatorCQCr7dsymbol7DsymbolSQDl7globals3LocPSQEc6dscope5ScopePSQEu4root5array__T5ArrayTCQFtQz10rootobject10RootObjectZQBmCQHb5mtype4TypePSQHrQCxQCv__TQCsTCQIi10expression10ExpressionZQDzPPxaZv
(pMessage=0x0, fargs=0x7fffff6c7540, tthis=0x0, tiargs=0x0, sc=0x7ffffdfb0500,
loc=..., dstart=0x7fffff6c6660, m=...) at dmd/dtemplate.d:3076

_D3dmd4func15resolveFuncCallFKxSQBe7globals3LocPSQBv6dscope5ScopeCQCm7dsymbol7DsymbolPSQDh4root5array__T5ArrayTCQEgQz10rootobject10RootObjectZQBmCQFo5mtype4TypePSQGeQCxQCv__TQCsTCQGv10expression10ExpressionZQDzEQIbQIa15FuncResolveFlagZCQJaQIz15FuncDeclaration
(flags=0 '\000', fargs=0x7fffff6c7540, tthis=0x0, tiargs=0x0, s=0x7fffff6c6660,
sc=0x7ffffdfb0500, loc=...) at dmd/func.d:2856

(this=0x7ffffffec4a8, exp=0x7fffff6c74e0) at dmd/expressionsem.d:4835

v=0x7ffffffec4a8) at dmd/expression.d:4975

(e=0x7fffff6c74e0, sc=0x7ffffdfb0500) at dmd/expressionsem.d:11497

(this=0x7ffffffec578, s=0x7fffff6c75c0) at dmd/statementsem.d:186

v=0x7ffffffec578) at dmd/statement.d:750

(s=0x7fffff6c75c0, sc=0x7ffffdfb0500) at dmd/statementsem.d:131

(this=0x7ffffffec8c8, cs=0x7fffff6c75f0) at dmd/statementsem.d:244

(this=0x7fffff6c75f0, v=0x7ffffffec8c8) at dmd/statement.d:938

(s=0x7fffff6c75f0, sc=0x7ffffdfb0500) at dmd/statementsem.d:131

(this=0x7ffffffed3a0, funcdecl=0x7fffff6c71f0) at dmd/semantic3.d:575

(this=0x7fffff6c71f0, v=0x7ffffffed3a0) at dmd/func.d:2558

sc=0x7ffffdfb01f0) at dmd/semantic3.d:81

(this=0x7ffffffed450, mod=0x7fffff6c4d20) at dmd/semantic3.d:194

v=0x7ffffffed450) at dmd/dmodule.d:1462

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

(params=..., argv=0x7ffffffee028, argc=5) at dmd/mars.d:597


--
Jul 07 2020