Menu

#43 Templates accessed via interface won't link

open
nobody
None
4
2008-04-19
2008-04-08
Kornel
No

The following code fails to link:

Undefined symbols:
"__D5test213TestInterface10__T3tplTiZ3tplMFZv", referenced from:
__Dmain in test.o

The code:

interface TestInterface
{
void tpl(T)();
}

class TestImplementation : TestInterface
{
void tpl(T)()
{
}
}

void main()
{
/* TestImplementation t = new TestImplementation(); // works */

TestInterface t = new TestImplementation(); // fails

t.tpl!(int)();
}

I'm using i686-apple-darwin8-gdc-4.0.1. It's unaffected by -femit-templates switch.

Discussion

  • David Friedman

    David Friedman - 2008-04-19

    Logged In: YES
    user_id=1378044
    Originator: NO

    The sample code is actually invalid and the compiler should be reporting an error. (Virtual template member functions are not allowed.)

    I have opened a bug against the DMD front end: http://d.puremagic.com/issues/show_bug.cgi?id=2015

     
  • David Friedman

    David Friedman - 2008-04-19
    • priority: 5 --> 4
     

Log in to post a comment.

Auth0 Logo