www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Sort bug with interfaces

interface A {}
class B:A { int opCmp(Object o) { printf("*"); return 0; } }

void main() {
B[] a;
a ~= new B();
a ~= new B();
a.sort;		// ok
printf("1. ok\n");

A[] b;
b ~= new B();
b.sort;		// ok, doesn't call opCmp since b.length==1
printf("2. ok\n");

A[] c;
c ~= new B();
c ~= new B();
c.sort;		//SEGFAULT!
printf("3. ok\n");
}

//It should be possible to sort elements in a interface-type-array
//since all array elements inherit opCmp from Object.
Aug 31 2005