summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2018-10-25 16:25:54 +0200
committerNikita Popov <nikita.ppv@gmail.com>2018-10-25 16:37:41 +0200
commitf1ceec5533c5ee0e1de7867d629f336f1353f4b3 (patch)
treef2dc1f8657f00d074d8ee63072dc18ad782ad51a
parente7153e8a2f5ea6e2b2d2b5afe558deebf518f04a (diff)
downloadphp-git-f1ceec5533c5ee0e1de7867d629f336f1353f4b3.tar.gz
Fixed bug #77058
Account for the fact that undef must be interpreted as null for the purposes of INC/DEC inference.
-rw-r--r--NEWS3
-rw-r--r--ext/opcache/Optimizer/zend_inference.c4
-rw-r--r--ext/opcache/tests/bug77058.phpt20
3 files changed, 24 insertions, 3 deletions
diff --git a/NEWS b/NEWS
index f90f0b0fbe..c801b72b4e 100644
--- a/NEWS
+++ b/NEWS
@@ -2,7 +2,8 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2018, PHP 7.1.25
-
+- Opcache:
+ . Fixed bug #77058 (Type inference in opcache causes side effects). (Nikita)
08 Nov 2018, PHP 7.1.24
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--
+<?php
+
+function myfunc(){
+ $Nr = 0;
+ while(1){
+ $x--;
+ $x++;
+ if( ++ $Nr >= 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