Bug 10425 – Link error with templates

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
Linux
Creation time
2013-06-20T09:05:00Z
Last change time
2013-09-24T23:56:11Z
Keywords
link-failure, pull
Assigned to
nobody
Creator
siegelords_abode

Comments

Comment #0 by siegelords_abode — 2013-06-20T09:05:03Z
DMD version 2.063.0 through .2. Worked ok in 2.062. 32/64 bit Linux. This needs two files, test.d and bug.d /////////// module test; import bug; void main() { } /////////// module bug; struct A() { int opCmp(const ref A p) const { return 0; } string toString() { return ""; } } struct B() { void foo() { auto a = new A!(); } } struct C { alias A!() a_t; this(B!() b) { } } When compiled this way there are no errors: dmd test.d bug.d However, when compiled this way I get link errors: dmd -c bug.d && dmd test.d bug.o test2.o:(.data._D23TypeInfo_S3bug6__T1AZ1A6__initZ+0x40): undefined reference to `_D3bug6__T1AZ1A5opCmpMxFKxS3bug6__T1AZ1AZi' test2.o:(.data._D23TypeInfo_S3bug6__T1AZ1A6__initZ+0x48): undefined reference to `_D3bug6__T1AZ1A8toStringMFZAya'
Comment #1 by andrej.mitrovich — 2013-06-20T09:30:06Z
Tried on Windows but it works there, it's maybe a posix-only issue.
Comment #2 by hsteoh — 2013-06-29T11:03:51Z
Reproduced this problem on my Linux amd64 box with dmd git HEAD.
Comment #3 by hsteoh — 2013-06-29T11:42:04Z
git bisect indicates that the offending commit was 67fbf5753e9d4a276c354e952ed2f888efcb714c, which was apparently a fix for issue 7511.
Comment #4 by k.hara.pg — 2013-09-21T21:39:47Z
The link-failure could see also on Windows 64bit codegen (use -m64). dmd -m64 -c bug.d && dmd -m64 test.d bug.obj Compiler fix: https://github.com/D-Programming-Language/dmd/pull/2582
Comment #5 by github-bugzilla — 2013-09-24T23:55:35Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/19ee7cb21fdbe52d6d773698ca5474922d43457b fix Issue 10425 - Link error with templates https://github.com/D-Programming-Language/dmd/commit/80e75140c569d7a2bd9b402dff42eef140c748cf Merge pull request #2582 from 9rnsr/fix10425 [REG2.062] Issue 10425 - Link error with templates