Bug 9101 – template mixin constructor causes link error

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
Windows
Creation time
2012-12-01T03:25:00Z
Last change time
2012-12-12T12:55:22Z
Keywords
link-failure, pull
Assigned to
nobody
Creator
r.sagitario

Comments

Comment #0 by r.sagitario — 2012-12-01T03:25:00Z
With latest dmd from github, this code produces a link error: class Node { int id; this() { } this(int tok) { id = tok; } mixin template ForwardCtorNoId() { this() {} // default constructor needed for clone() this(int tok) { super(tok); } } } class Derived : Node { mixin ForwardCtorNoId!(); } void main() { } This does not happen with dmd 2.060 and using bisect, it seems to be introduced with this commit: 8bc59cfe8e6896435f20ce1e9bdcc226942f59a8 fix Issue 5893 - Allow simple aliases for operator overloading A work around seems to be to move the mixin declaration out of the base class scope.
Comment #1 by r.sagitario — 2012-12-01T09:53:35Z
Forgot to post the error message: >dmd.exe test.d OPTLINK (R) for Win32 Release 8.00.11 Copyright (C) Digital Mars 1989-2010 All rights reserved. http://www.digitalmars.com/ctg/optlink.html test.obj(test) Error 42: Symbol Undefined _D4test4Node21__T15ForwardCtorNoIdZ6__ctorMFZC4test4 Node --- errorlevel 1
Comment #2 by k.hara.pg — 2012-12-04T19:25:58Z
(In reply to comment #0) > This does not happen with dmd 2.060 and using bisect, it seems to be introduced > with this commit: 8bc59cfe8e6896435f20ce1e9bdcc226942f59a8 fix Issue 5893 - > Allow simple aliases for operator overloading > > A work around seems to be to move the mixin declaration out of the base class > scope. Both newest git head (2f50520) and the trunk commit which merged pull #980 (2888ec4) doesn't occur such link error in Windows. But, in current I use optlink 8.00.5 > link OPTLINK (R) for Win32 Release 8.00.5 Copyright (C) Digital Mars 1989-2009 All rights reserved. http://www.digitalmars.com/ctg/optlink.html Might this be a optkink bug?
Comment #3 by r.sagitario — 2012-12-05T00:14:58Z
It's not the linker, the symbol is referenced from within the object file. The problem is triggered by my precise GC patches in druntime where generation of RTInfo needs to iterate over the members of the class. The bad operation boils down to static if (__traits(compiles, Node.ForwardCtorNoId.offset+1)) {} When added to the test case, the error appears with the standard druntime, too. The derived class is not needed then.
Comment #4 by k.hara.pg — 2012-12-12T00:07:53Z
(In reply to comment #3) > It's not the linker, the symbol is referenced from within the object file. > > The problem is triggered by my precise GC patches in druntime where generation > of RTInfo needs to iterate over the members of the class. The bad operation > boils down to > > static if (__traits(compiles, Node.ForwardCtorNoId.offset+1)) {} > > When added to the test case, the error appears with the standard druntime, too. > The derived class is not needed then. OK, the original case has been broken by fixing issue 5893 certainly. But following shrinked code causes same linker error, and it has been caused same linker error from before fixing 5893. ---- class Node { template ForwardCtorNoId() { this() {} // default constructor void foo() { 0 = 1; } // wrong code } } enum x = __traits(compiles, Node.ForwardCtorNoId!()); void main() {} ---- Therefore, the root cause was not a regression. But your code actually be broken in 2.061head. So I'd like to keep this issue marked as regression. Thanks.
Comment #5 by k.hara.pg — 2012-12-12T00:28:36Z
Comment #6 by github-bugzilla — 2012-12-12T02:56:08Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/9e36de3edaabe74c7f81f1ebe563ecd8186c960c fix Issue 9101 - template mixin constructor causes link error https://github.com/D-Programming-Language/dmd/commit/c4dc64092ae2ae8d774ae5d9b2af5b440dfff40f Merge pull request #1367 from 9rnsr/fix9101 Issue 9101 - template mixin constructor causes link error