[Issue 13478] New: [REG2.066] Templates not emitted when also referenced in speculative contexts

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Sep 15 08:27:10 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=13478

          Issue ID: 13478
           Summary: [REG2.066] Templates not emitted when also referenced
                    in speculative contexts
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: code at klickverbot.at

---
module a;
import b;
import c;
int main() {
   return foo!int();
}
---
module b;
bool foo(T)() {
    // Make sure this is not inlined so a.o actually needs
    // to reference it.
    asm { nop; }
    return false;
}
---
module c;
import b;
// Note that foo is only used in the template constraint here,
// so this never causes foo!int to be emitted. 
T barImpl(T)(T t) if (is(typeof({ foo!T(); }))) { return t; }
int bar(int a) { return barImpl(a); }
---

Compile with "dmd -inline a.d".

(If it bothers you, you can also do "dmd -c c.d" first and add c.o to the
command line. It shouldn't make a difference and indeed doesn't.)

DMD 2.066 does not emit foo!int to a.o.

--


More information about the Digitalmars-d-bugs mailing list