Skip to content

Commit d246584

Browse files
committed
Merge branch 'PHP-8.4'
* PHP-8.4: Ensure that type widening converges
2 parents a88a5ec + d68fd73 commit d246584

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ PHP NEWS
88
. Fixed bug GH-19637 (Incorrect Closure scope for FCC in constant
99
expression). (timwolla)
1010
. Fixed bug GH-19613 (Stale array iterator pointer). (ilutov)
11+
. Fixed bug GH-19679 (zend_ssa_range_widening may fail to converge). (Arnaud)
1112

1213
- Date:
1314
. Fixed date_sunrise() and date_sunset() with partial-hour UTC offset.

Zend/Optimizer/zend_inference.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,12 +1623,16 @@ static bool zend_inference_widening_meet(zend_ssa_var_info *var_info, zend_ssa_r
16231623
r->min < var_info->range.min) {
16241624
r->underflow = 1;
16251625
r->min = ZEND_LONG_MIN;
1626+
} else {
1627+
r->min = var_info->range.min;
16261628
}
16271629
if (r->overflow ||
16281630
var_info->range.overflow ||
16291631
r->max > var_info->range.max) {
16301632
r->overflow = 1;
16311633
r->max = ZEND_LONG_MAX;
1634+
} else {
1635+
r->max = var_info->range.max;
16321636
}
16331637
if (var_info->range.min == r->min &&
16341638
var_info->range.max == r->max &&

Zend/tests/gh19679.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
GH-19679: zend_ssa_range_widening does not converge
3+
--SKIPIF--
4+
<?php
5+
if (PHP_INT_SIZE !== 8) {
6+
die('skip output depends PHP_INT_SIZE=8');
7+
}
8+
?>
9+
--FILE--
10+
<?php
11+
function test() {
12+
$a = PHP_INT_MIN+1;
13+
$b = 0;
14+
while ($b++ < 3) {
15+
$a = (int) ($a-- - $b - 1);
16+
}
17+
return $a;
18+
}
19+
var_dump(test() == PHP_INT_MIN);
20+
?>
21+
--EXPECT--
22+
bool(true)

0 commit comments

Comments
 (0)