July 01, 2004 dmd crash: struct sorting | ||||
---|---|---|---|---|
| ||||
The following will crash dmd: /////// struct S { } void main () { S [] s; s.sort; } /////// ----------------------- Carlos Santander Bernal |
July 05, 2004 Re: dmd crash: struct sorting | ||||
---|---|---|---|---|
| ||||
Posted in reply to Carlos Santander B. | 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 > > |
Copyright © 1999-2021 by the D Language Foundation