[Issue 281] New: dmd generates the object code ld cannot link when working with templates

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Aug 9 15:34:44 PDT 2006


http://d.puremagic.com/issues/show_bug.cgi?id=281

           Summary: dmd generates the object code ld cannot link when
                    working with templates
           Product: D
           Version: 0.163
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: link-failure
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: tbolsh at gmail.com


try to compile the following code with dmd:

import std.boxer;
import std.stdio;

class Test{
    char []txt;
    this(char []txt) { this.txt = txt; }
    char []toString(){ return txt; }
}
void main(char [][]args){
    Test t1 = new Test("test");
    Box  tb = box( t1 );
    Test t2 = unbox!(Test) (tb);
}

It compiles fine, but ld generates following errors:

[tbolsh]$ dmd TestBoxer
gcc TestBoxer.o -o TestBoxer -m32 -lphobos -lpthread -lm
TestBoxer.o(.gnu.linkonce.t_D3std5boxer27__T5unboxTC9TestBoxer4TestZ5unboxFS3std5boxer3BoxZC9TestBoxer4Test+0x1a):
In function
`_D3std5boxer27__T5unboxTC9TestBoxer4TestZ5unboxFS3std5boxer3BoxZC9TestBoxer4Test':
TestBoxer.d: undefined reference to `_assert_3std5boxer'
collect2: ld returned 1 exit status
--- errorlevel 1

GDC compiles and links such a code fine.


-- 




More information about the Digitalmars-d-bugs mailing list