mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
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:
parent
37b1226af1
commit
b65b15c6f4
2 changed files with 21 additions and 0 deletions
19
Zend/tests/assert/indirect_var_access_misoptimization.phpt
Normal file
19
Zend/tests/assert/indirect_var_access_misoptimization.phpt
Normal 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)
|
|
@ -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")) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue