Menu

#40 template instantiation failure

open
nobody
None
5
2008-03-02
2008-03-02
No

Hi, I'm seeing a template instantiation failure when two modules import each other and both modules instantiate the same template (with same template arguments). I am seeing this on both linux/x86 and darwin/x86 with the r199 trunk gdc. A minimal testcase is attached.

Here is the link-time failure that I see (this text is from darwin/x86 but I get something similar on linux/x86):

/usr/bin/ld: Undefined symbols:
__D5tango4util10collection8ArraySeq23__T8ArraySeqTC3job3JobZ8ArraySeq5_ctorMFZC5tango4util10collection8ArraySeq23__T8ArraySeqTC3job3JobZ8ArraySeq
__D5tango4util10collection8ArraySeq23__T8ArraySeqTC3job3JobZ8ArraySeq6appendMFC3job3JobZv
__D5tango4util10collection8ArraySeq23__T8ArraySeqTC3job3JobZ8ArraySeq7__ClassZ
collect2: ld returned 1 exit status

Discussion

  • Jey Kottalam

    Jey Kottalam - 2008-03-02

    reduced testcase exhibiting the problem

     
  • Jey Kottalam

    Jey Kottalam - 2008-03-02

    Logged In: YES
    user_id=15267
    Originator: YES

    Additional notes:

    - I also see this bug under GDC 0.24
    - adding -femit-templates=private works around the problem

     
  • David Friedman

    David Friedman - 2008-04-20

    Logged In: YES
    user_id=1378044
    Originator: NO

    It is better to use -femit-templates=all (unless the target does not support templates.)

    This is actually the result of DMD's template logic and the same error will occur with DMD if each module is compiled separately. This means you could also use gdmd's '-fall-sources' option as a workaround.

     

Log in to post a comment.

Auth0 Logo