D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 17259 - ICE with multiple mixin templates containing conflicting ctor declarations
Summary: ICE with multiple mixin templates containing conflicting ctor declarations
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 critical
Assignee: No Owner
URL:
Keywords: ice, pull
Depends on:
Blocks:
 
Reported: 2017-03-15 23:14 UTC by hsteoh
Modified: 2019-03-12 13:06 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description hsteoh 2017-03-15 23:14:14 UTC
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@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).
Comment 1 hsteoh 2017-03-15 23:15:18 UTC
Possibly related to: https://issues.dlang.org/show_bug.cgi?id=9235
Comment 2 Dlang Bot 2019-03-10 23:43:26 UTC
@Basile-z updated dlang/dmd pull request #9441 "fix 17259 -  ICE with multiple mixin templates containing conflicting…" fixing this issue:

- fix issue 17259 -  ICE with multiple mixin templates containing conflicting ctor declarations
  
  This only fixes the ICE, not the fact that resolution should work, as explained in https://issues.dlang.org/show_bug.cgi?id=19729

https://github.com/dlang/dmd/pull/9441
Comment 3 Dlang Bot 2019-03-12 13:06:32 UTC
dlang/dmd pull request #9441 "fix 17259 -  ICE with multiple mixin templates containing conflicting…" was merged into stable:

- 0e8a09a539068a7c04deb35a0fd7b9ecfc1becd9 by Basile Burg:
  fix issue 17259 -  ICE with multiple mixin templates containing conflicting ctor declarations
  
  This only fixes the ICE, not the fact that resolution should work, as explained in https://issues.dlang.org/show_bug.cgi?id=19729

https://github.com/dlang/dmd/pull/9441