ID:               49973
 Updated by:       j...@php.net
 Reported By:      php dot vope at gishpuppy dot com
-Status:           Open
+Status:           Closed
 Bug Type:         Filter related
 Operating System: Linux x86 64-bit
 PHP Version:      5.2.11
 New Comment:

This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.




Previous Comments:
------------------------------------------------------------------------

[2009-10-23 15:19:45] php dot vope at gishpuppy dot com

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 this bug report at http://bugs.php.net/?id=49973&edit=1

Reply via email to