#47422 [NEW]: modulus operator returns incorrect results on 64 bit linux

From: Date: Tue, 17 Feb 2009 12:36:14 +0000
Subject: #47422 [NEW]: modulus operator returns incorrect results on 64 bit linux
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-133906@lists.php.net to get a copy of this message
From: d_kelsey at uk dot ibm dot com Operating system: Linux 64Bit PHP version: 5.2CVS-2009-02-17 (CVS) PHP Bug Type: Scripting Engine problem Bug description: modulus operator returns incorrect results on 64 bit linux Description: ------------ on a 64bit system the following var_dump(1%4294967295); should return 1, but returns 0. The problem is in the ZEND_API int mod_function(...) in zend_operators.c A call is made to abs which expects a 32bit int and returns a 32bit int, but 4294967295 is > 32 bits in size so the abs call returns an incorrect value. A proposed fix is to change the line "if (abs(op2->value.lval) == 1) {" to "if (op2->value.lval == 1 || op2->value.lval == -1) {" -- Edit bug report at http://bugs.php.net/?id=47422&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=47422&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=47422&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=47422&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=47422&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=47422&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=47422&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=47422&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=47422&r=needscript Try newer version: http://bugs.php.net/fix.php?id=47422&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=47422&r=support Expected behavior: http://bugs.php.net/fix.php?id=47422&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=47422&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=47422&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=47422&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47422&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=47422&r=dst IIS Stability: http://bugs.php.net/fix.php?id=47422&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=47422&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=47422&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=47422&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=47422&r=mysqlcfg

« previous php.bugs (#133906) next »