Skip to content

Commit 88cf395

Browse files
committed
Add test for php#11917
1 parent ca53391 commit 88cf395

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

tests/basic/bug11917.phpt

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
--TEST--
2+
Bug #11917 (primitives seem to be passed via reference instead of by value under some conditions when JIT is enabled on windows)
3+
--FILE--
4+
<?php
5+
$a = [2147483647,2147483647,2147483647,3,0,0,32,2147483584,127];
6+
echo crc32(json_encode(bitwise_small_split($a))) . "\n";
7+
echo crc32(json_encode(bitwise_small_split($a))) . "\n";
8+
echo crc32(json_encode(bitwise_small_split($a))) . "\n";
9+
echo crc32(json_encode(bitwise_small_split($a))) . "\n";
10+
11+
function bitwise_small_split($val)
12+
{
13+
$split = 8;
14+
$vals = [];
15+
16+
$mask = (1 << $split) - 1;
17+
18+
$i = $overflow = 0;
19+
$len = count($val);
20+
$val[] = 0;
21+
$remaining = 31;
22+
23+
while ($i != $len) {
24+
$digit = $val[$i] & $mask;
25+
26+
$val[$i] >>= $split;
27+
if (!$overflow) {
28+
$remaining -= $split;
29+
$overflow = $split <= $remaining ? 0 : $split - $remaining;
30+
31+
if (!$remaining) {
32+
$i++;
33+
$remaining = 31;
34+
$overflow = 0;
35+
}
36+
} elseif (++$i != $len) {
37+
$tempmask = (1 << $overflow) - 1;
38+
$digit |= ($val[$i] & $tempmask) << $remaining;
39+
$val[$i] >>= $overflow;
40+
$remaining = 31 - $overflow;
41+
$overflow = $split <= $remaining ? 0 : $split - $remaining;
42+
}
43+
44+
$vals[] = $digit;
45+
}
46+
47+
while ($vals[count($vals) - 1] == 0) {
48+
unset($vals[count($vals) - 1]);
49+
}
50+
51+
return array_reverse($vals);
52+
}
53+
?>
54+
--EXPECT--
55+
48207660
56+
48207660
57+
48207660
58+
48207660

0 commit comments

Comments
 (0)