com php-src: Mark assert() as INDIRECT_VAR_ACCESS: Zend /tests/assert/indirect_var_access_misoptimization.phpt ext/opcache/Optimizer/zend_cfg.c

From: Date: Tue, 17 May 2016 14:13:17 +0000
Subject: com php-src: Mark assert() as INDIRECT_VAR_ACCESS: Zend /tests/assert/indirect_var_access_misoptimization.phpt ext/opcache/Optimizer/zend_cfg.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-92166@lists.php.net to get a copy of this message
Commit: b65b15c6f470cc3397ff7719d92cecc762c803e9 Author: Nikita Popov <nikic@php.net> Tue, 17 May 2016 16:13:17 +0200 Parents: 37b1226af16ec2cf95ffb7c2a8158ae064d8bf9d Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b65b15c6f470cc3397ff7719d92cecc762c803e9 Log: 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. Changed paths: A Zend/tests/assert/indirect_var_access_misoptimization.phpt M ext/opcache/Optimizer/zend_cfg.c Diff: diff --git a/Zend/tests/assert/indirect_var_access_misoptimization.phpt b/Zend/tests/assert/indirect_var_access_misoptimization.phpt new file mode 100644 index 0000000..61c193a --- /dev/null +++ b/Zend/tests/assert/indirect_var_access_misoptimization.phpt @@ -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) diff --git a/ext/opcache/Optimizer/zend_cfg.c b/ext/opcache/Optimizer/zend_cfg.c index ee03363..4ea7387 100644 --- a/ext/opcache/Optimizer/zend_cfg.c +++ b/ext/opcache/Optimizer/zend_cfg.c @@ -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")) {

« previous php.cvs (#92166) next »