www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13478] New: [REG2.066] Templates not emitted when also


          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 puremagic.com
          Reporter: code 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.

Sep 15 2014