From: [EMAIL PROTECTED] Operating system: Solaris PHP version: 5.2.1 PHP Bug Type: Arrays related Bug description: compiler optimization bug randomizes array sorting
Description: ------------ Because the wrong type is used for the return value from the qsort callback function, the compiler screws up the actual return value, causing the sort to be incorrect. The following diff avoids the bug by explicitly return the "right" values: cvs diff: Diffing . Index: array.c =================================================================== RCS file: /repository/php-src/ext/standard/array.c,v retrieving revision 1.308.2.21.2.25 diff -u -p -r1.308.2.21.2.25 array.c --- array.c 16 Mar 2007 19:38:58 -0000 1.308.2.21.2.25 +++ array.c 18 Mar 2007 20:03:36 -0000 @@ -596,7 +596,7 @@ static int array_user_compare(const void convert_to_long_ex(&retval_ptr); retval = Z_LVAL_P(retval_ptr); zval_ptr_dtor(&retval_ptr); - return retval; + return retval < 0 ? -1 : retval > 0 ? 1 : 0; } else { return 0; } -- Edit bug report at http://bugs.php.net/?id=40848&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40848&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40848&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40848&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=40848&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=40848&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=40848&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=40848&r=needscript Try newer version: http://bugs.php.net/fix.php?id=40848&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=40848&r=support Expected behavior: http://bugs.php.net/fix.php?id=40848&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=40848&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=40848&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=40848&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40848&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=40848&r=dst IIS Stability: http://bugs.php.net/fix.php?id=40848&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=40848&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=40848&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=40848&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=40848&r=mysqlcfg