1--TEST-- 2gmp_setbit() with large index 3--SKIPIF-- 4<?php if (getenv("TRAVIS") === "true") die("skip not suitable for Travis-CI"); ?> 5<?php if (!extension_loaded("gmp")) print "skip"; ?> 6<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); ?> 7<?php if (getenv("SKIP_SLOW_TESTS")) die("skip slow test"); ?> 8<?php 9 /* This test requires about 8G RAM which likely not to be present on an arbitrary CI. */ 10 if (!file_exists("/proc/meminfo")) { 11 die("skip cannot determine free memory amount."); 12 } 13 $s = file_get_contents("/proc/meminfo"); 14 $free = 0; 15 if (preg_match(",MemFree:\s+(\d+)\s+kB,", $s, $m)) { 16 /* Got amount in kb. */ 17 $free = $m[1]/1024/1024; 18 } 19 if ($free < 8) { 20 die("skip not enough free RAM."); 21 } 22?> 23--FILE-- 24<?php 25 26$n = gmp_init("227200"); 27for($a = 1<<30; $a > 0 && $a < 0x8000000000; $a <<= 2) { 28 $i = $a - 1; 29 printf("%X\n", $i); 30 try { 31 gmp_setbit($n, $i, 1); 32 } catch (\ValueError $e) { 33 echo $e->getMessage() . \PHP_EOL; 34 } 35} 36echo "Done\n"; 37?> 38--EXPECTF-- 393FFFFFFF 40FFFFFFFF 413FFFFFFFF 42FFFFFFFFF 433FFFFFFFFF 44gmp_setbit(): Argument #2 ($index) must be less than %d * %d 45Done 46