xref: /PHP-8.4/ext/opcache/tests/jit/bug81225.phpt (revision c16ad918)
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=tracing
9--SKIPIF--
10<?php if (PHP_INT_SIZE != 8) die("skip: 64-bit only"); ?>
11--FILE--
12<?php
13
14function unsignedLong(int $offset): int
15{
16    $normalizedOffset = $offset % (2 ** 32);
17
18    if ($normalizedOffset < 0) {
19        $normalizedOffset += 2 ** 32;
20    }
21
22    return $normalizedOffset;
23}
24
25$offset = -0x100000000 + 2;
26
27for ($i = 0; $i < 200; ++$i) {
28    assert(unsignedLong($offset) === 2);
29}
30?>
31OK
32--EXPECT--
33OK
34