www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - sorting a BigInt[] with algorithm.sort()

reply Charles McAnany <mcanance rose-hulman.edu> writes:
Hi, all. This is a strange one.
import std.bigint;
import std.algorithm;
void main(){
BigInt[] ar = [BigInt(2), BigInt(1), BigInt(3)];
sort(ar);
}

object.Exception src\rt\arraycat.d(40): overlapping array copy

Is this a library bug? Or is sort() not supposed to work on this data?


Oh, additionally,
bool res = ar[0] < ar[1]; compiles and executes just fine, as does the normal
swapping algorithm:
BigInt t = ar[0];
ar[0] = ar[1];
ar[1] = t;

Thanks,
Charles.
Jun 16 2011
parent bearophile <bearophileHUGS lycos.com> writes:
Charles McAnany:

 object.Exception src\rt\arraycat.d(40): overlapping array copy
 
 Is this a library bug? Or is sort() not supposed to work on this data?

It's a known bug: http://d.puremagic.com/issues/show_bug.cgi?id=5705 (Is Bugzilla down?) Bye, bearophile
Jun 16 2011