[Issue 12993] New: DMD keeps references to symbols removed

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Jun 25 21:28:43 PDT 2014


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

          Issue ID: 12993
           Summary: DMD keeps references to symbols removed
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: Jesse.K.Phillips+D at gmail.com
                CC: Jesse.K.Phillips+D at gmail.com

The following code causes DMD to keep a reference to a symbol it does not
output to the object file. At least that is the best explanation I have. A
number of modifications will cause it to compile and link and where marked with
numbered comments.

DMD 2.065 and 2.066-devel-a6a2682

------------
template wrap(Targets...)
{
    template wrap(Source)
    {
        auto wrap(Source src) {
            return new Impl(src); // 5: remove (Not solution for dmd 2.065)
        }

                     // 3: Structural is not a template
        class Impl : Structural!Source, Targets // 4: remove Targets
        {
            this(Source s){ }
        public:
            override int quack() { return 3; } // 4: remove
        }
    }
}

interface Structural(T) {} // 3: don't use template

unittest
{
    interface Quack
    {
        int quack();
    }
    class Human
    {
    }

    Human h1 = new Human();

    interface Refleshable{}

    enum a = __traits(compiles, h1.wrap!Refleshable); // 1: remove

    h1.wrap!Quack; // 2: remove
}
-------------
$ dmd -unittest -main type2.d

type2.o:(.data._D5type243__T4wrapTC5type215__unittestL17_1FZv5QuackZ43__T4wrapTC5type215__unittestL17_1FZv5HumanZ4Impl7__ClassZ+0x98):
undefined reference to
`_D5type250__T10StructuralTC5type215__unittestL17_1FZv5HumanZ10Structural11__InterfaceZ'

--


More information about the Digitalmars-d-bugs mailing list