xref: /PHP-8.0/ext/opcache/tests/jit/bug81225.phpt (revision ee981619)
1--TEST--
2Bug #81225: Wrong result with pow operator with JIT enabled
3--INI--
4opcache.enable=1
5opcache.enable_cli=1
6opcache.jit_buffer_size=1M
7opcache.jit=tracing
8--SKIPIF--
9<?php require_once('skipif.inc'); ?>
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