Status: New
Owner: ----
New issue 2604 by songya...@gmail.com:
Arrray.prototype.sort(comparefn) :comparefn may cause wrong result when
returning bool value
http://code.google.com/p/v8/issues/detail?id=2604
If comparefn return bool value and Array length is greater than 10 ,the
result in v8 may be wrong.
var test10Elements = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0];
var test11Elements = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0];
var compareFn = function (x, y) {
return x > y;
};
test10Elements.sort(compareFn);
test11Elements.sort(compareFn);
console.log("sorted test10Elements:",test10Elements);
console.log("sorted test11Elements:",test11Elements);
IE10 safari5.17 sorted test10Elements:9,8,7,6,5,4,3,2,1,0
sorted test11Elements:10,9,8,7,6,5,4,3,2,1,0
firefox19 sorted test10Elements: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
sorted test11Elements: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10]
chrome26 sorted test10Elements: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
sorted test11Elements: [5, 0, 1, 2, 3, 4, 6, 7, 8, 9, 10]
ES5 spec :
If comparefn is not undefined, it should be a function that accepts two
arguments x and y and returns a negative value if x < y, zero if x = y, or
a positive value if x > y.
I notice firefox treat the return value of comparefn to double.
I'm not sure this is a v8 issue,because the spec is not specify the return
value of comparefn shoud be wrapped by user or spec implementers.
Attachments:
array.patch 1.3 KB
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.