Bug 19691 – ICE on null default value for struct parameter in constructor
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-02-21T14:34:09Z
Last change time
2020-03-21T03:56:36Z
Keywords
ice, pull
Assigned to
No Owner
Creator
Simen Kjaeraas
Comments
Comment #0 by simen.kjaras — 2019-02-21T14:34:09Z
This code:
struct S1 {
this(T...)(T) {
S2("");
}
}
struct S2 {
this(string) {}
this(S1 s = null) {}
}
Crashes the compiler (2.084.1). I've not been able to reduce it to a simple overload problem. That is, this does not exhibit the same issue:
struct S1 {
this(T...)(T) {
fun("");
}
}
void fun(S1 s = null) {}
void fun(string s) {}
Comment #1 by b2.temp — 2019-02-28T12:37:21Z
That's a regression, 2.075.z: https://run.dlang.io/is/vqQyCh
- The bug doesn't happen if you change the order of declaration, i.e S2 before S1
- The bug happens because of a null scope:
Program received signal SIGSEGV, Segmentation fault.
0x00000000005b6a01 in DsymbolSemanticVisitor::visit(CtorDeclaration*) (this=0x7fffffff97b0,
ctd=0x7ffff6d46370) at dmd/dsymbolsem.d:3708
3708 ctd.parent = sc.parent;
Missing separate debuginfos, use: dnf debuginfo-install libgcc-8.2.1-6.fc28.x86_64
(gdb)
(gdb) bt
#0 0x00000000005b6a01 in DsymbolSemanticVisitor::visit(CtorDeclaration*) (this=0x7fffffff97b0,
ctd=0x7ffff6d46370) at dmd/dsymbolsem.d:3708
#1 0x000000000060fdf2 in CtorDeclaration::accept(Visitor*) (this=0x7ffff6d46370, v=0x7fffffff97b0)
at dmd/func.d:3373
#2 0x00000000005ac291 in dsymbolSemantic(Dsymbol*, Scope*) (dsym=0x7ffff6d46370, sc=0x0) <--- here, null scope
at dmd/dsymbolsem.d:365
#3 0x00000000005c345d in _D3dmd9dtemplate15functionResolveFPSQBi11declaration5MatchCQCf7dsymbol7DsymbolSQCz7globals3LocPSQDq6dscope5ScopePSQEi4root5array__T5ArrayTCQFhQz10rootobject10RootObjectZQBmCQGp5mtype4TypePSQHfQCxQCv__TQCsTCQHw10expression10ExpressionZQDzPPxaZ13applyFunctionMFCQJy4func15FuncDeclarationZi (__capture=0x7fffffff9a00, fd=0x7ffff6d46370) at dmd/dtemplate.d:2411
#4 0x00000000005c481e in _D3dmd9dtemplate15functionResolveFPSQBi11declaration5MatchCQCf7dsymbol7DsymbolSQCz7globals3LocPSQDq6dscope5ScopePSQEi4root5array__T5ArrayTCQFhQz10rootobject10RootObjectZQBmCQGp5mtype4TypePSQHfQCxQCv__TQCsTCQHw10expression10ExpressionZQDzPPxaZ10__lambda11MFQHqZi (
__capture=0x7fffffff9a00, s=0x7ffff6d46370) at dmd/dtemplate.d:2814
#5 0x000000000060e20c in _D3dmd4func13overloadApplyFCQBa7dsymbol7DsymbolMDFQxZiPSQCc6dscope5ScopeZi (sc=0x7ffff6aa55f0, dg=..., fstart=0x7ffff6d45e00) at dmd/func.d:2566
---Type <return> to continue, or q <return> to quit---
#6 0x00000000005c3149 in _D3dmd9dtemplate15functionResolveFPSQBi11declaration5MatchCQCf7dsymbol7DsymbolSQCz7globals3LocPSQDq6dscope5ScopePSQEi4root5array__T5ArrayTCQFhQz10rootobject10RootObjectZQBmCQGp5mtype4TypePSQHfQCxQCv__TQCsTCQHw10expression10ExpressionZQDzPPxaZv (pMessage=0x0,
fargs=0x7ffff6aa4b70, tthis=0x7ffff6d46860, tiargs=0x0, sc=0x7ffff6aa55f0, loc=...,
dstart=0x7ffff6d45e00, m=0x7fffffff9a48) at dmd/dtemplate.d:2818
#7 0x000000000060e522 in _D3dmd4func15resolveFuncCallFKxSQBe7globals3LocPSQBv6dscope5ScopeCQCm7dsymbol7DsymbolPSQDh4root5array__T5ArrayTCQEgQz10rootobject10RootObjectZQBmCQFo5mtype4TypePSQGeQCxQCv__TQCsTCQGv10expression10ExpressionZQDzEQIbQIa15FuncResolveFlagZCQJaQIz15FuncDeclaration (
flags=0 '\000', fargs=0x7ffff6aa4b70, tthis=0x7ffff6d46860, tiargs=0x0, s=0x7ffff6d45e00,
sc=0x7ffff6aa55f0, loc=...) at dmd/func.d:2721
#8 0x00000000005f1eba in ExpressionSemanticVisitor::visit(CallExp*) (this=0x7fffffffa4b8,
exp=0x7ffff6aa5950) at dmd/expressionsem.d:4327
#9 0x00000000005e0656 in CallExp::accept(Visitor*) (this=0x7ffff6aa5950, v=0x7fffffffa4b8)
at dmd/expression.d:4892
#10 0x0000000000606333 in expressionSemantic(Expression*, Scope*) (e=0x7ffff6aa5950,
sc=0x7ffff6aa55f0) at dmd/expressionsem.d:10777
---Type <return> to continue, or q <return> to quit---
#11 0x00000000005f1972 in ExpressionSemanticVisitor::visit(CallExp*) (this=0x7fffffffac48,
exp=0x7ffff6aa4b20) at dmd/expressionsem.d:4193
#12 0x00000000005e0656 in CallExp::accept(Visitor*) (this=0x7ffff6aa4b20, v=0x7fffffffac48)
at dmd/expression.d:4892
#13 0x0000000000606333 in expressionSemantic(Expression*, Scope*) (e=0x7ffff6aa4b20,
sc=0x7ffff6aa55f0) at dmd/expressionsem.d:10777
#14 0x00000000006a1cce in StatementSemanticVisitor::visit(ExpStatement*) (this=0x7fffffffad18,
s=0x7ffff6aa4b00) at dmd/statementsem.d:176
#15 0x00000000006812ae in ExpStatement::accept(Visitor*) (this=0x7ffff6aa4b00, v=0x7fffffffad18)
at dmd/statement.d:738
#16 0x00000000006a1bb7 in statementSemantic(Statement*, Scope*) (s=0x7ffff6aa4b00,
sc=0x7ffff6aa55f0) at dmd/statementsem.d:125
#17 0x00000000006a1f90 in StatementSemanticVisitor::visit(CompoundStatement*) (
this=0x7fffffffb048, cs=0x7ffff6aa4ac0) at dmd/statementsem.d:234
#18 0x0000000000681b0e in CompoundStatement::accept(Visitor*) (this=0x7ffff6aa4ac0,
v=0x7fffffffb048) at dmd/statement.d:935
---Type <return> to continue, or q <return> to quit---
#19 0x00000000006a1bb7 in statementSemantic(Statement*, Scope*) (s=0x7ffff6aa4ac0,
sc=0x7ffff6aa55f0) at dmd/statementsem.d:125
#20 0x00000000006b6e9e in Semantic3Visitor::visit(FuncDeclaration*) (this=0x7fffffffbba0,
funcdecl=0x7ffff6aa4680) at dmd/semantic3.d:573
#21 0x00000000006b9c1f in Semantic3Visitor::visit(CtorDeclaration*) (this=0x7fffffffbba0,
ctor=0x7ffff6aa4680) at dmd/semantic3.d:1318
#22 0x000000000060fdf2 in CtorDeclaration::accept(Visitor*) (this=0x7ffff6aa4680, v=0x7fffffffbba0)
at dmd/func.d:3373
#23 0x00000000006b57b5 in semantic3(Dsymbol*, Scope*) (dsym=0x7ffff6aa4680, sc=0x7ffff6aa3ed0)
at dmd/semantic3.d:82
#24 0x0000000000609482 in FuncDeclaration::functionSemantic3() (this=0x7ffff6aa4680)
at dmd/func.d:420
#25 0x0000000000609398 in FuncDeclaration::functionSemantic() (this=0x7ffff6aa4680)
at dmd/func.d:394
#26 0x000000000060e568 in _D3dmd4func15resolveFuncCallFKxSQBe7globals3LocPSQBv6dscope5ScopeCQCm7dsymbol7DsymbolPSQDh4root5array__T5ArrayTCQEgQz10rootobject10RootObjectZQBmCQFo5mtype4TypePSQGeQCxQCv__T---Type <return> to continue, or q <return> to quit---
QCsTCQGv10expression10ExpressionZQDzEQIbQIa15FuncResolveFlagZCQJaQIz15FuncDeclaration (
flags=0 '\000', fargs=0x7ffff6aa32d0, tthis=0x7ffff6d45b60, tiargs=0x0, s=0x7ffff6d45800,
sc=0x7ffff6aa3070, loc=...) at dmd/func.d:2729
#27 0x00000000005f1eba in ExpressionSemanticVisitor::visit(CallExp*) (this=0x7fffffffc6c8,
exp=0x7ffff6aa3280) at dmd/expressionsem.d:4327
#28 0x00000000005e0656 in CallExp::accept(Visitor*) (this=0x7ffff6aa3280, v=0x7fffffffc6c8)
at dmd/expression.d:4892
#29 0x0000000000606333 in expressionSemantic(Expression*, Scope*) (e=0x7ffff6aa3280,
sc=0x7ffff6aa3070) at dmd/expressionsem.d:10777
#30 0x0000000000625005 in _D3dmd7initsem19initializerSemanticRCQBj4init11InitializerPSQCg6dscope5ScopeCQCx5mtype4TypeEQDmQCd13NeedInterpretZ8visitExpMFCQEuQDl14ExpInitializerZQEj (
__capture=0x7fffffffc850, i=0x7ffff6aa3180) at dmd/initsem.d:457
#31 0x0000000000623483 in initializerSemantic(Initializer*, Scope*, Type*, NeedInterpret) (
init=0x7ffff6aa3180, sc=0x7ffff6aa3070, t=0x7ffff6d45b60, needInterpret=<incomplete type>)
at dmd/initsem.d:523
#32 0x000000000068b06e in _D3dmd7typesem12typeSemanticRCQBc5mtype4TypeSQBr7globals3LocPSQCi6dscope5S---Type <return> to continue, or q <return> to quit---
copeZ13visitFunctionMFCQDrQCp12TypeFunctionZQDl (__capture=0x7fffffffcb70, mtype=0x7ffff6d462b0)
at dmd/typesem.d:1353
#33 0x0000000000688bea in typeSemantic(Type*, Loc, Scope*) (t=0x7ffff6d462b0, loc=...,
sc=0x7ffff6aa2d70) at dmd/typesem.d:1814
#34 0x00000000005b4bd7 in DsymbolSemanticVisitor::funcDeclarationSemantic(FuncDeclaration*) (
this=0x7fffffffd240, funcdecl=0x7ffff6d46370) at dmd/dsymbolsem.d:3093
#35 0x00000000005b6b24 in DsymbolSemanticVisitor::visit(CtorDeclaration*) (this=0x7fffffffd240,
ctd=0x7ffff6d46370) at dmd/dsymbolsem.d:3735
#36 0x000000000060fdf2 in CtorDeclaration::accept(Visitor*) (this=0x7ffff6d46370, v=0x7fffffffd240)
at dmd/func.d:3373
#37 0x00000000005ac291 in dsymbolSemantic(Dsymbol*, Scope*) (dsym=0x7ffff6d46370,
sc=0x7ffff6aa2680) at dmd/dsymbolsem.d:365
#38 0x00000000005b8f34 in _D3dmd10dsymbolsem22DsymbolSemanticVisitor5visitMRCQBx7dstruct17StructDeclarationZ__T9__lambda5TCQDr7dsymbol7DsymbolZQBgMFQBaZv (__capture=0x7fffffffd440, s=0x7ffff6d46370)
at dmd/dsymbolsem.d:4295
#39 0x00000000005a66bc in _D3dmd7dsymbol14foreachDsymbolFPSQBf4root5array__T5ArrayTCQCeQCd7DsymbolZQ---Type <return> to continue, or q <return> to quit---
xMDFQvZvZv (dg=..., symbols=0x7ffff6d45c10) at dmd/dsymbol.d:97
#40 0x00000000005b88a6 in DsymbolSemanticVisitor::visit(StructDeclaration*) (this=0x7fffffffd490,
sd=0x7ffff6d46620) at dmd/dsymbolsem.d:4295
#41 0x00000000005a6142 in StructDeclaration::accept(Visitor*) (this=0x7ffff6d46620,
v=0x7fffffffd490) at dmd/dstruct.d:592
#42 0x00000000005ac291 in dsymbolSemantic(Dsymbol*, Scope*) (dsym=0x7ffff6d46620,
sc=0x7ffff6d46af0) at dmd/dsymbolsem.d:365
#43 0x00000000005b16a8 in _D3dmd10dsymbolsem22DsymbolSemanticVisitor5visitMRCQBx7dmodule6ModuleZ__T9__lambda2TCQDf7dsymbol7DsymbolZQBgMFQBaZv (__capture=0x7fffffffd540, s=0x7ffff6d46620)
at dmd/dsymbolsem.d:1979
#44 0x00000000005a66bc in _D3dmd7dsymbol14foreachDsymbolFPSQBf4root5array__T5ArrayTCQCeQCd7DsymbolZQxMDFQvZvZv (dg=..., symbols=0x7ffff6d45030) at dmd/dsymbol.d:97
#45 0x00000000005b1634 in DsymbolSemanticVisitor::visit(Module*) (this=0x7fffffffd590,
m=0x7ffff6d44d80) at dmd/dsymbolsem.d:1976
#46 0x0000000000594d7a in Module::accept(Visitor*) (this=0x7ffff6d44d80, v=0x7fffffffd590)
at dmd/dmodule.d:1290
---Type <return> to continue, or q <return> to quit---
#47 0x00000000005ac291 in dsymbolSemantic(Dsymbol*, Scope*) (dsym=0x7ffff6d44d80, sc=0x0)
at dmd/dsymbolsem.d:365
#48 0x0000000000649553 in _D3dmd4mars7tryMainFmPPxaKSQz7globals5ParamZi (params=...,
argv=0x7fffffffdf98, argc=2) at dmd/mars.d:560
#49 0x000000000064aaf5 in D main () at dmd/mars.d:859
Maybe it's possible at some point to launch the semantic of the other thing when the scope is null probably at step #3 or #4
The reduction is actually slightly different. With the upcoming fix the initial test case will pass an fall back on the string overload (even if with a dep message) but the reduction will fail.
Comment #4 by dlang-bot — 2019-02-28T13:32:16Z
@Basile-z created dlang/dmd pull request #9397 "fix issue 19691 - ICE on null default value for struct parameter in constructor" fixing this issue:
- fix issue 19691 - ICE on null default value for struct parameter in constructor
https://github.com/dlang/dmd/pull/9397
Comment #5 by dlang-bot — 2019-03-01T22:28:34Z
dlang/dmd pull request #9397 "fix issue 19691 - ICE on null default value for struct parameter in constructor" was merged into master:
- 81b0ed15918bfc3608b28e443121fa7bc982f5d8 by Basile Burg:
fix issue 19691 - ICE on null default value for struct parameter in constructor
https://github.com/dlang/dmd/pull/9397
Comment #6 by dlang-bot — 2019-06-16T20:57:33Z
dlang/dmd pull request #10046 "[dmd-cxx] Backport semanticRun refactoring and recursive semantic SEGV bug fixes" was merged into dmd-cxx:
- b90e1fdd85d62c535f22944540ab7ca525d57bb2 by Basile Burg:
fix issue 19691 - ICE on null default value for struct parameter in constructor
https://github.com/dlang/dmd/pull/10046