xref: /PHP-8.1/ext/opcache/tests/jit/bug81225.phpt (revision ee981619)
1--TEST--
2Bug #81225: Wrong result with pow operator with JIT enabled
3--EXTENSIONS--
4opcache
5--INI--
6opcache.enable=1
7opcache.enable_cli=1
8opcache.jit_buffer_size=1M
9opcache.jit=tracing
10--SKIPIF--
11<?php if (PHP_INT_SIZE != 8) die("skip: 64-bit only"); ?>
12--FILE--
13<?php
14
15function unsignedLong(int $offset): int
16{
17    $normalizedOffset = $offset % (2 ** 32);
18
19    if ($normalizedOffset < 0) {
20        $normalizedOffset += 2 ** 32;
21    }
22
23    return $normalizedOffset;
24}
25
26$offset = -0x100000000 + 2;
27
28for ($i = 0; $i < 200; ++$i) {
29    assert(unsignedLong($offset) === 2);
30}
31?>
32OK
33--EXPECT--
34OK
35