digitalmars.D.bugs - [Issue 8769] New: Template instantiation emitted into wrong file on multi-obj compilation
- d-bugmail puremagic.com (57/57) Oct 06 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8769
- d-bugmail puremagic.com (12/12) Apr 07 2013 http://d.puremagic.com/issues/show_bug.cgi?id=8769
http://d.puremagic.com/issues/show_bug.cgi?id=8769 Summary: Template instantiation emitted into wrong file on multi-obj compilation Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: code klickverbot.at --- Comment #0 from klickverbot <code klickverbot.at> 2012-10-06 12:09:43 PDT --- Consider the following test case: --- // algorithm.d auto filter(alias pred, Range)(Range rs) { return FilterResult!(pred, Range)(rs); } struct FilterResult(alias pred, Range) { this(Range r) {} } --- --- // file.d import algorithm; struct DirIterator {} auto dirEntries() { void f() {} return filter!f(DirIterator()); } void main() {} --- --- dmd -c algorithm.d file.d dmd algorithm.o file.o # Works fine # Now recompile algorithm. dmd -c algorithm.d # ... and try to link again: dmd algorithm.o file.o --- The second attempt to link fails with file.d:(.text._D4file10dirEntriesFZS4file10dirEntries66__T12FilterResultS25_D4file10dirEntries1fMFZvTS4file11DirIteratorZ12FilterResult59__T6filterS25_D4file10dirEntries1fMFZvTS4file11DirIteratorZ6filterMFS4file11DirIteratorZS4file10dirEntries66__T12FilterResultS25_D4file10dirEntries1fMFZvTS4file11DirIteratorZ12FilterResult+0x1e): undefined reference to `_D4file10dirEntriesFZS4file10dirEntries66__T12FilterResultS25_D4file10dirEntries1fMFZvTS4file11DirIteratorZ12FilterResult66__T12FilterResultS25_D4file10dirEntries1fMFZvTS4file11DirIteratorZ12FilterResult6__ctorMFS4file11DirIteratorZS4file10dirEntries66__T12FilterResultS25_D4file10dirEntries1fMFZvTS4file11DirIter torZ12FilterResult' because DMD initially emitted the symbol in question to algorithm.o instead of file.o. I'm not quite sure about an easy way to fix this. The simple heuristic in https://github.com/D-Programming-Language/dmd/blob/67681b916f7880432c7da14a714404af0254278e/src/template.c#L4854 unfortunately fails once algorithm.d is present on the command line itself, because then (<algorithm>.importedFrom == <algorithm>). We likely need to track the template instantiation "origin" over the whole chain. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 06 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8769 Martin Nowak <code dawg.eu> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |code dawg.eu Resolution| |DUPLICATE --- Comment #1 from Martin Nowak <code dawg.eu> 2013-04-07 12:04:53 PDT --- *** This issue has been marked as a duplicate of issue 3274 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 07 2013