Bug 17259 – ICE with multiple mixin templates containing conflicting ctor declarations

Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2017-03-15T23:14:14Z
Last change time
2019-03-12T13:06:32Z
Keywords
ice, pull
Assigned to
No Owner
Creator
hsteoh

Comments

Comment #0 by hsteoh — 2017-03-15T23:14:14Z
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 by hsteoh — 2017-03-15T23:15:18Z
Comment #2 by dlang-bot — 2019-03-10T23:43:26Z
@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 by dlang-bot — 2019-03-12T13:06:32Z
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