From: php dot vope at gishpuppy dot com Operating system: Linux x86 64-bit PHP version: 5.2.11 PHP Bug Type: Filter related Bug description: Filter PHPT fails on 64-bit. PHPT testcase incorrectly uses ~(PHPT_INT_MAX-1).
Description: ------------ The PHPT test ext\filter\046.phpt fails when run on a 64-bit system. The problem is likely to be that ~(PHP_INT_MAX)-1 is not sufficient to create an underflow on 64-bit. This is because a float on 64-bit has less bits than an integer ( since it needs some for the exponent ). The test would pass if ~(PHP_INT_MAX)-2000 was used instead. On 64-bit ~(PHP_INT_MAX)-2000 = float(-9223372036854777856) which would be enough of a difference to make the test valid. Thanks in advance, Tim Preece Reproduce code: --------------- From http://svn.php.net/repository/php/php-src/branches/PHP_5_2/ext/filter/tests/046.phpt. --TEST-- Integer overflow --SKIPIF-- <?php if (!extension_loaded("filter")) die("skip"); ?> --FILE-- <?php $s = sprintf("%d", PHP_INT_MAX); var_dump(is_long(filter_var($s, FILTER_VALIDATE_INT))); $s = sprintf("%.0f", PHP_INT_MAX+1); var_dump(filter_var($s, FILTER_VALIDATE_INT)); $s = sprintf("%d", -PHP_INT_MAX); var_dump(is_long(filter_var($s, FILTER_VALIDATE_INT))); $s = sprintf("%.0f", ~(PHP_INT_MAX)-1); var_dump(filter_var($s, FILTER_VALIDATE_INT)); ?> --EXPECT-- bool(true) bool(false) bool(true) bool(false) Expected result: ---------------- --EXPECT-- bool(true) bool(false) bool(true) bool(false) Actual result: -------------- On a 64-bit system: bool(true) bool(false) bool(true) int(-9223372036854775808) -- Edit bug report at http://bugs.php.net/?id=49973&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=49973&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=49973&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=49973&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=49973&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=49973&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=49973&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=49973&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=49973&r=needscript Try newer version: http://bugs.php.net/fix.php?id=49973&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=49973&r=support Expected behavior: http://bugs.php.net/fix.php?id=49973&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=49973&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=49973&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=49973&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=49973&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=49973&r=dst IIS Stability: http://bugs.php.net/fix.php?id=49973&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=49973&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=49973&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=49973&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=49973&r=mysqlcfg