Bug 63226

Summary: Array.sort( func ) broken if func returns ± Infinity
Product: [Applications] konqueror Reporter: zack-weg
Component: kjsAssignee: Konqueror Developers <konq-bugs>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:

Description zack-weg 2003-08-25 11:11:21 UTC
Version:            (using KDE KDE 3.1.2)
Installed from:    Gentoo Packages
Compiler:          gcc 3.2.3 
OS:          Linux

This gives [Infinity, 0] instead of [0, Infinity]:

  [0, Infinity].sort( function ( a, b ) { return a - b } );

sort() doesn't seem to handle ±Infinity as return values of the
compare function correctly. ECMAScript doesn't exclude ±Infinity as possible return values.
Comment 1 zack-weg 2003-08-25 11:44:41 UTC
Actually, every return value not fitting into 32 bit fails.
Comment 2 zack-weg 2003-08-27 01:06:49 UTC
After looking at the code, this seems to fixed with revision 1.48 of
kdelibs/kjs/array_object.cpp , but I leave this bug open until I can verify in
the next release.

http://webcvs.kde.org/cgi-bin/cvsweb.cgi/kdelibs/kjs/array_object.cpp#rev1.48
Comment 3 Harri Porten 2003-09-30 15:03:32 UTC
Your test case (added to khtmltests/js/Array.js) indeed works with
current CVS. Closing.