From: ronlentjes at yahoo dot com dot au Operating system: Linux Fedora 8 PHP version: 5.3.0 PHP Bug Type: Scripting Engine problem Bug description: Integer Wrap stopped working properly
Description: ------------ Old version are correct. Eg 4.2.2 is exhibiting correct integer behavior. Wrapping issue. All tests on 40 other languages pass according to this simple test: Ver 4.2.2 $n = 2147483647; $n = (int) ($n + 1) -> -2147483648 (+wrap, correct) $n = (int) ($n - 1) -> 2147483647 (-wrap, correct) (C/C++/C#/.../assembly inc,dec/perl(int mode)/python/so on follow this logic) Ver 5.2.4 $n = 2147483647; $n = (int) ($n + 1) -> -2147483648 (+wrap, correct) $n = (int) ($n - 1) -> -2147483648 (-max, wrong) (no other language follow this. Some languages do use +/-max but not this mix of wrap one way and max the other) Suggest: back to original +/- wrapping. Your newer versions are wrong. You wrap going positive around the integer wheel. You don't wrap going negative around the integer wheel. One direction you wrap, the other direction you do a max. I test all languages and this is incorrect integer behavior. Your original logic was correct but now broken and affects all original source code. Related issue by someone else: #30315. Got closed but core issue misunderstood. Cheers, Ron Lentjes, LC CLS. Reproduce code: --------------- Sorry, didn't see these boxes. See above. Your version is irrelavent here as I am talking about a change from old to new versionS. New ones don't work. (I could not select irrelavent so just chose one on list - but that's not the point). -- Edit bug report at http://bugs.php.net/?id=49207&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=49207&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=49207&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=49207&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=49207&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=49207&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=49207&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=49207&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=49207&r=needscript Try newer version: http://bugs.php.net/fix.php?id=49207&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=49207&r=support Expected behavior: http://bugs.php.net/fix.php?id=49207&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=49207&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=49207&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=49207&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=49207&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=49207&r=dst IIS Stability: http://bugs.php.net/fix.php?id=49207&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=49207&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=49207&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=49207&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=49207&r=mysqlcfg