www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Link Error with template code.

Hi everyone,

This message is posted in following the other message I posted before regarding
link error when using template. The following code has been trimmed to its
possible smallest size and can still produce the problems. It seems to me that
the compiler mistakenly forgets to generate some code and eventually when the
linker kicks in, there is no code to link with. However, this is only my

Could anyone please help me figure out what the actual problem is?



public interface Iterator(ValueType) {

public interface Collection(ValueType) {
public Iterator!(ValueType) iterator();

public interface List(ValueType) : Collection!(ValueType) {

public class ArrayList(ValueType) : List!(ValueType) {
public Iterator!(ValueType) iterator() {
return new ArrayListIterator!(ValueType)();

public class ArrayListIterator(ValueType) : Iterator!(ValueType) {

void main()
// comment out the next line will cause link error. This must be comp bug.
// typedef Iterator!(int) IntItor;

ArrayList!(int) iarray = new ArrayList!(int)();


// strange! If comment out the next line, you will get "Terminated" message
// printf("Here!!!\n");
Jun 28 2004