[Issue 18906] New: Template specialisations should not be stripped if they're not called

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri May 25 07:49:56 UTC 2018


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

          Issue ID: 18906
           Summary: Template specialisations should not be stripped if
                    they're not called
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: turkeyman at gmail.com

extern(C++) class C
{
  T t(T)(T x);
  int t(T : int)(int x)
  {
    return x * 2;
  }
}

Given the code above, the symbol `t!int` will NOT be emit to the object unless
something somewhere calls that instantiation.
I think this is wrong, an explicit specialisation like this needs to go in the
object file regardless, it was hand-written, and it might be used externally
(in my case, it is used externally).

Likewise, we should have a method to force an instantiation of a template into
the object like C++ has. For instance, C++ for the above:
  `template float C::t<float>(float);`

Causes explicit instantiation of the template for float.

Perhaps D already has this syntax, but I don't know what it is?

--


More information about the Digitalmars-d-bugs mailing list