mirror of
https://github.com/php/php-src.git
synced 2026-03-24 08:12:21 +01:00
Don't const evaluate increment of array in SCCP
This commit is contained in:
@@ -704,6 +704,10 @@ static inline int ct_eval_assign_obj(zval *result, zval *value, zval *key) {
|
||||
}
|
||||
|
||||
static inline int ct_eval_incdec(zval *result, zend_uchar opcode, zval *op1) {
|
||||
if (Z_TYPE_P(op1) == IS_ARRAY || IS_PARTIAL_ARRAY(op1)) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
ZVAL_COPY(result, op1);
|
||||
if (opcode == ZEND_PRE_INC
|
||||
|| opcode == ZEND_POST_INC
|
||||
|
||||
27
ext/opcache/tests/inc_array.phpt
Normal file
27
ext/opcache/tests/inc_array.phpt
Normal file
@@ -0,0 +1,27 @@
|
||||
--TEST--
|
||||
Do not constant fold increment of array
|
||||
--FILE--
|
||||
<?php
|
||||
function test_inc_array() {
|
||||
$a = [];
|
||||
$a++;
|
||||
}
|
||||
function test_inc_partial_array($k) {
|
||||
$a = [];
|
||||
$a[$k] = 0;
|
||||
$a++;
|
||||
}
|
||||
try {
|
||||
test_inc_array();
|
||||
} catch (TypeError $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
try {
|
||||
test_inc_partial_array(0);
|
||||
} catch (TypeError $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
Cannot increment array
|
||||
Cannot increment array
|
||||
Reference in New Issue
Block a user