forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix some int/long confusion issues in GMP
mpz_setbit seems to have limit of INT_MAX * GMP_NUMB_BITS on the number of bits supported, and will abort() if that limit is exceeded.
- Loading branch information
Showing
2 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--TEST-- | ||
gmp_setbit() with large index | ||
--SKIPIF-- | ||
<?php if (!extension_loaded("gmp")) print "skip"; ?> | ||
<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); ?> | ||
<?php if (getenv("SKIP_SLOW_TESTS")) die("skip slow test"); ?> | ||
--FILE-- | ||
<?php | ||
|
||
$n = gmp_init("227200"); | ||
for($a = 1<<30; $a > 0 && $a < 0x8000000000; $a <<= 2) { | ||
$i = $a - 1; | ||
printf("%X\n", $i); | ||
gmp_setbit($n, $i, 1); | ||
} | ||
echo "Done\n"; | ||
?> | ||
--EXPECTF-- | ||
3FFFFFFF | ||
FFFFFFFF | ||
3FFFFFFFF | ||
FFFFFFFFF | ||
3FFFFFFFFF | ||
|
||
Warning: gmp_setbit(): Index must be less than %d * %d in %s/gmp_setbit_long.php on line %d | ||
Done |