digitalmars.D.bugs - dmd crash: struct sorting
- Carlos Santander B. (11/11) Jun 30 2004 The following will crash dmd:
- Jarrett Billingsley (21/32) Jul 05 2004 oops. i think i hit "email" instead of "reply". oh well, i'll post it ...
The following will crash dmd: /////// struct S { } void main () { S [] s; s.sort; } /////// ----------------------- Carlos Santander Bernal
Jun 30 2004
oops. i think i hit "email" instead of "reply". oh well, i'll post it here for public reference as well. adding an opCmp() declaration to the struct seems to fix it. struct A { int opCmp(A other) { return 0; } } int main() { A[] array; array.sort; return 0; } probably what's happening is that structs do not have a default opCmp as classes do. though it would be nice if the compiler flagged an error saying that you need to define an opCmp to sort a struct array. :) "Carlos Santander B." <carlos8294 msn.com> wrote in message news:cbvntq$20uu$2 digitaldaemon.com...The following will crash dmd: /////// struct S { } void main () { S [] s; s.sort; } /////// ----------------------- Carlos Santander Bernal
Jul 05 2004