bug in std.algorithm.sort ??
KennyTM~
kennytm at gmail.com
Thu Jun 4 05:45:15 PDT 2009
A.M. wrote:
> import std.string;
> import std.array;
> import std.algorithm;
>
> void main()
> {
> string[] sa = ["TOM","JOE","TOM4","TOM12","TOM6"];
> sort!(comp)(sa);
> }
> bool comp(string x, string y)
> {
> string[] s = [x,y];
> return isSorted(s);
> }
>
> this code compiles find, but when run gives the following error:
>
> core.exception.AssertError at ./../../src/phobos/std/array.d(210): Attempting to fetch the front of an empty array
>
> I'm using dmd2.030
> same happens with dmd2.029
>
> is that a bug?
No. Because comp("foo", "foo") == true, but should return false when the
two keys are equal.
BTW, the following code can reproduce your "bug":
import std.algorithm;
void main() {
sort!("a <= b")( [2,1].dup );
}
More information about the Digitalmars-d
mailing list