TypePHP 编译器 https://swoole.com/aot/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

25 lines
485 B

--TEST--
SSA narrowing: int overflow prevention (PHP_INT_MAX)
--FILE--
<?php
use varint_types;
function main(): void {
$a = 2;
// $a + PHP_INT_MAX overflows to float at runtime
$b = $a + PHP_INT_MAX;
echo gettype($b), PHP_EOL;
// $a * PHP_INT_MAX also overflows
$c = $a * PHP_INT_MAX;
echo gettype($c), PHP_EOL;
// Even small int arithmetic must keep PHP overflow semantics.
$d = $a + 99;
var_dump($d);
}
?>
--EXPECT--
double
double
int(101)