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

--- Comment #0 from klickverbot <> 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

undefined reference to

because DMD initially emitted the symbol in question to algorithm.o instead of

I'm not quite sure about an easy way to fix this. The simple heuristic in
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

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to