[Issue 17259] New: ICE with multiple mixin templates containing conflicting ctor declarations
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Mar 15 16:14:14 PDT 2017
https://issues.dlang.org/show_bug.cgi?id=17259
Issue ID: 17259
Summary: ICE with multiple mixin templates containing
conflicting ctor declarations
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: critical
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: hsteoh at quickfur.ath.cx
Code:
------
mixin template Templ(T) {
this() { }
}
class C {
mixin Templ!int;
mixin Templ!float;
}
void main() {
auto c = new C;
}
------
Compiler output:
------
test.d: Error: overloadset test.C.__ctor is aliased to a function
core.exception.AssertError at ddmd/func.d(4136): Assertion failure
----------------
dmd() [0x5a58e5]
dmd(_Z15resolveFuncCall3LocP5ScopeP7DsymbolP5ArrayIP10RootObjectEP4TypePS4_IP10ExpressionEi+0x42b)
[0x5a2073]
dmd(_ZN6NewExp8semanticEP5Scope+0xcc1) [0x57a721]
dmd(_ZN14ExpInitializer9inferTypeEP5Scope+0x26) [0x5b65f6]
dmd(_ZN14VarDeclaration8semanticEP5Scope+0x150) [0x526858]
dmd(_ZN14DeclarationExp8semanticEP5Scope+0xa9) [0x57d101]
dmd(_ZN24StatementSemanticVisitor5visitEP12ExpStatement+0x52) [0x60c1b2]
dmd(_ZN12ExpStatement6acceptEP7Visitor+0x1a) [0x6004da]
dmd(ddmd.statement.Statement
ddmd.statementsem.semantic(ddmd.statement.Statement, ddmd.dscope.Scope*)+0x41)
[0x619531]
dmd(_ZN24StatementSemanticVisitor5visitEP17CompoundStatement+0xe8) [0x60c448]
dmd(_ZN17CompoundStatement6acceptEP7Visitor+0x1a) [0x600c42]
dmd(ddmd.statement.Statement
ddmd.statementsem.semantic(ddmd.statement.Statement, ddmd.dscope.Scope*)+0x41)
[0x619531]
dmd(_ZN15FuncDeclaration9semantic3EP5Scope+0x120c) [0x59b2b4]
dmd(_ZN6Module9semantic3EP5Scope+0x6c) [0x54664c]
dmd(int ddmd.mars.tryMain(ulong, const(char)**)+0x2f43) [0x5c90a3]
dmd(_Dmain+0x27) [0x5c9cd7]
dmd(_D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv+0x1f)
[0x70652f]
dmd(void rt.dmain2._d_run_main(int, char**, extern (C) int
function(char[][])*).tryExec(scope void delegate())+0x2a) [0x706482]
dmd(void rt.dmain2._d_run_main(int, char**, extern (C) int
function(char[][])*).runAll()+0x30) [0x7064e8]
dmd(void rt.dmain2._d_run_main(int, char**, extern (C) int
function(char[][])*).tryExec(scope void delegate())+0x2a) [0x706482]
dmd(_d_run_main+0x1dc) [0x7063fc]
dmd(main+0x12) [0x5ca3c2]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf1) [0x7fd3820fd2b1]
------
Arguably, the code is invalid (but see below), but the compiler should not ICE
just because of that.
I said "arguably" because changing "this() {}" to "~this() {}" not only makes
the error go away, but also causes the multiple dtors to get aggregated and
even merged with any dtors defined explicitly in class C, so that upon class
destruction all the instances of ~this() get invoked. This causes one to wonder
if this is an undocumented feature. Which then raises the question of why the
asymmetry with ctors, that multiple definitions of the default ctor is rejected
(and leads to an ICE).
--
More information about the Digitalmars-d-bugs
mailing list