Bug 8997 – template instances omit symbol that may be used in other modules
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-11-11T10:16:00Z
Last change time
2014-01-18T18:28:25Z
Keywords
link-failure, pull
Assigned to
nobody
Creator
deadalnix
Comments
Comment #0 by deadalnix — 2012-11-11T10:16:37Z
See cod below :
module linkfailclass;
class A {
A[string] foobar;
}
module linkfailuse;
import linkfailclass;
void main() {
auto a = new A();
foreach(key; a.foobar.byKey()) {
}
}
Then compile :
dmd -c linkfailclass.d
dmd -c linkfailuse.d
dmd -oflinkfail linkfailclass.o linkfailuse.o
linkfailuse.o: In function `_Dmain':
linkfailuse.d:(.text._Dmain+0x20): undefined reference to `_D6object45__T16AssociativeArrayTAyaTC13linkfailclass1AZ16AssociativeArray5byKeyMFNdZS6object45__T16AssociativeArrayTAyaTC13linkfailclass1AZ16AssociativeArray5byKeyM6Result'
linkfailuse.d:(.text._Dmain+0x29): undefined reference to `_D6object45__T16AssociativeArrayTAyaTC13linkfailclass1AZ16AssociativeArray5Range5emptyMxFNdZb'
linkfailuse.d:(.text._Dmain+0x36): undefined reference to `_D6object45__T16AssociativeArrayTAyaTC13linkfailclass1AZ16AssociativeArray5byKeyMFNdZS6object45__T16AssociativeArrayTAyaTC13linkfailclass1AZ16AssociativeArray5byKeyM6Result6Result5frontMFNcNdZAya'
linkfailuse.d:(.text._Dmain+0x46): undefined reference to `_D6object45__T16AssociativeArrayTAyaTC13linkfailclass1AZ16AssociativeArray5Range8popFrontMFZv'
collect2: error: ld returned 1 exit status
--- errorlevel 1
Template is instantiated in linkfailclass so linkfailuse assume it is in it. But some members of the template are not instanciated because not used in linkfailclass. linkfailuse assume they are.