[Issue 311] New: Object files missing certain template instantiations
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Aug 26 03:11:44 PDT 2006
http://d.puremagic.com/issues/show_bug.cgi?id=311
Summary: Object files missing certain template instantiations
Product: D
Version: 0.165
Platform: PC
OS/Version: Linux
Status: NEW
Keywords: link-failure
Severity: major
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: oskar.linde at gmail.com
This is a very old infamous linking error that only appears when compiling the
modules separately on DMD, and always on GDC (that only supports one module at
a time compilation).
The smallest example I have found that triggers the bug is a three module
import chain a->b->c, where b instantiates a template in c, and the template in
c instantiates another template in c. The code for this other template never
gets written to any object file.
The workaround is to add an import c; in a.
---------- a.d ---------
import b;
//import c;
void main() { func(); }
---------- b.d ---------
import c;
void func()() { C(); }
---------- c.d ---------
void C(T=int)() { C!(double)(); }
------------------------
$ dmd -c a.d
$ dmd -c b.d
$ dmd -c c.d
$ dmd a.o b.o c.o
a.o: In function `_D1c8__T1CTiZ1CFZv':
a.d:(.gnu.linkonce.t_D1c8__T1CTiZ1CFZv+0x4): undefined reference to
`_D1c8__T1CTdZ1CFZv'
$ gdc a.d b.d c.d
/tmp/ccWsXe5T.o: In function `_D1c8__T1CTiZ1CFZv':
a.d:(.gnu.linkonce.t._D1c8__T1CTiZ1CFZv[_D1c8__T1CTiZ1CFZv]+0x7): undefined
reference to `_D1c8__T1CTdZ1CFZv'
$ dmd a.d b.d c.d
No error
Uncommenting the import c; in a.d makes the error go away.
I've not had the chance to verify this on any other platform than Linux.
DMD version 0.165 and GDC 0.17 was used.
/Oskar
--
More information about the Digitalmars-d-bugs
mailing list