From f1ceec5533c5ee0e1de7867d629f336f1353f4b3 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 25 Oct 2018 16:25:54 +0200 Subject: Fixed bug #77058 Account for the fact that undef must be interpreted as null for the purposes of INC/DEC inference. --- ext/opcache/Optimizer/zend_inference.c | 4 ++-- ext/opcache/tests/bug77058.phpt | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 ext/opcache/tests/bug77058.phpt (limited to 'ext/opcache') diff --git a/ext/opcache/Optimizer/zend_inference.c b/ext/opcache/Optimizer/zend_inference.c index 6aa823fdd2..39cab72195 100644 --- a/ext/opcache/Optimizer/zend_inference.c +++ b/ext/opcache/Optimizer/zend_inference.c @@ -2434,7 +2434,7 @@ static int zend_update_type_info(const zend_op_array *op_array, tmp |= MAY_BE_RCN; } } - if ((t1 & MAY_BE_ANY) == MAY_BE_LONG) { + if ((t1 & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_LONG) { if (!ssa_var_info[ssa_ops[i].op1_use].has_range || (opline->opcode == ZEND_PRE_DEC && (ssa_var_info[ssa_ops[i].op1_use].range.underflow || @@ -2496,7 +2496,7 @@ static int zend_update_type_info(const zend_op_array *op_array, if (t1 & (MAY_BE_RC1|MAY_BE_RCN)) { tmp |= MAY_BE_RC1; } - if ((t1 & MAY_BE_ANY) == MAY_BE_LONG) { + if ((t1 & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_LONG) { if (!ssa_var_info[ssa_ops[i].op1_use].has_range || (opline->opcode == ZEND_PRE_DEC && (ssa_var_info[ssa_ops[i].op1_use].range.underflow || diff --git a/ext/opcache/tests/bug77058.phpt b/ext/opcache/tests/bug77058.phpt new file mode 100644 index 0000000000..6a5a83cef7 --- /dev/null +++ b/ext/opcache/tests/bug77058.phpt @@ -0,0 +1,20 @@ +--TEST-- +Bug #77058: Type inference in opcache causes side effects +--FILE-- += 2 ) break; + } + echo "'$Nr' is expected to be 2", PHP_EOL; +} +myfunc(); + +?> +--EXPECTF-- +Notice: Undefined variable: x in %s on line %d +'2' is expected to be 2 -- cgit v1.2.1