Mark assert() as INDIRECT_VAR_ACCESS

I don't like this... we may want to detect "obviously not string"
operands by checking for the result of a comparison instruction.
This commit is contained in:
Nikita Popov 2016-05-17 16:13:17 +02:00
parent 37b1226af1
commit b65b15c6f4
2 changed files with 21 additions and 0 deletions

View file

@ -0,0 +1,19 @@
--TEST--
Misoptimization when variable is modified by assert()
--INI--
zend.assertions=1
--FILE--
<?php
function test() {
$i = 0;
assert('$i = new stdClass');
$i += 1;
var_dump($i);
}
test();
?>
--EXPECTF--
Notice: Object of class stdClass could not be converted to int in %s on line %d
int(2)

View file

@ -308,6 +308,8 @@ int zend_build_cfg(zend_arena **arena, const zend_op_array *op_array, uint32_t b
flags |= ZEND_FUNC_INDIRECT_VAR_ACCESS;
} else if (zend_string_equals_literal(Z_STR_P(zv), "get_defined_vars")) {
flags |= ZEND_FUNC_INDIRECT_VAR_ACCESS;
} else if (zend_string_equals_literal(Z_STR_P(zv), "assert")) {
flags |= ZEND_FUNC_INDIRECT_VAR_ACCESS;
} else if (zend_string_equals_literal(Z_STR_P(zv), "func_num_args")) {
flags |= ZEND_FUNC_VARARG;
} else if (zend_string_equals_literal(Z_STR_P(zv), "func_get_arg")) {