https://issues.dlang.org/show_bug.cgi?id=21299
Issue ID: 21299 Summary: [LINK] undefined reference to dmd.root.stringtable.StringValue!(Type).StringValue.ls tring() Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: blocker Priority: P1 Component: dmd Assignee: nob...@puremagic.com Reporter: ibuc...@gdcproject.org Reduced from link error found in regression from Issue 21294 (which caused a refactoring change in dmd to be reverted). It may not be *the* cause of the Issue 21294, but it's certainly a major issue that needs to be addressed, as this is preventing code in the dmd front-end from being moved around. Test script: ``` dmd -c dmd/mtype.d dmd -c dmd/func.d dmd -c dmd/root/stringtable.d dmd -main mtype.o func.o stringtable.o ``` Test sources ``` // dmd/func.d module dmd.func; import dmd.mtype; import dmd.root.stringtable; class FuncDeclaration { StringTable!Type stringtable; } // dmd/mtype.d module dmd.mtype; import dmd.func; import dmd.root.stringtable; class Type { StringTable!Type stringtable; } // dmd/root/stringtable.d module dmd.root.stringtable; struct StringValue(T) { char* lstring() { return cast(char*)&this; } } struct StringTable(T) { StringValue!T* insert() { allocValue; return getValue; } uint allocValue() { StringValue!(T) sv; sv.lstring[0] = 0; return 0; } StringValue!T* getValue() { return cast(StringValue!T*)&this; } } ``` Results in the link error: ``` /usr/bin/ld: mtype.o: in function `_D3dmd4root11stringtable__T11StringTableTCQBo5mtype4TypeZQBe10allocValueMFNaNbNiNfZk': dmd/mtype.d:(.text._D3dmd4root11stringtable__T11StringTableTCQBo5mtype4TypeZQBe10allocValueMFNaNbNiNfZk[_D3dmd4root11stringtable__T11StringTableTCQBo5mtype4TypeZQBe10allocValueMFNaNbNiNfZk]+0x13): undefined reference to `_D3dmd4root11stringtable__T11StringValueTCQBo5mtype4TypeZQBe7lstringMFNaNbNiNfZPa' collect2: error: ld returned 1 exit status Error: linker exited with status 1 ``` --