Bug 12993 – DMD keeps references to symbols removed
Status
RESOLVED
Resolution
WORKSFORME
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2014-06-26T04:28:43Z
Last change time
2020-03-21T03:56:33Z
Assigned to
No Owner
Creator
Jesse Phillips
Comments
Comment #0 by Jesse.K.Phillips+D — 2014-06-26T04:28:43Z
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'