Skip to content

Commit 5ae07dc

Browse files
committed
Fixed incorrect constant propagation
1 parent 6f8273e commit 5ae07dc

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

ext/opcache/Optimizer/zend_optimizer.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,9 @@ int zend_optimizer_update_op1_const(zend_op_array *op_array,
195195
opline->opcode = ZEND_SEND_VAL;
196196
opline->op1.constant = zend_optimizer_add_literal(op_array, val);
197197
break;
198-
case ZEND_SEND_VAR_NO_REF_EX:
199-
opline->opcode = ZEND_SEND_VAL_EX;
200-
opline->op1.constant = zend_optimizer_add_literal(op_array, val);
201-
break;
202198
case ZEND_SEPARATE:
203199
case ZEND_SEND_VAR_NO_REF:
200+
case ZEND_SEND_VAR_NO_REF_EX:
204201
zval_ptr_dtor(val);
205202
return 0;
206203
case ZEND_CONCAT:
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
Pass result of inlined function by reference
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.optimization_level=-1
7+
--SKIPIF--
8+
<?php require_once('skipif.inc'); ?>
9+
--FILE--
10+
<?php
11+
function get_const() {
12+
return 42;
13+
}
14+
15+
function test() {
16+
foo(get_const());
17+
}
18+
19+
if (true) {
20+
function foo(&$ref) {}
21+
}
22+
23+
test();
24+
?>
25+
OK
26+
--EXPECTF--
27+
Notice: Only variables should be passed by reference in %swrong_inlining_001.php on line 7
28+
OK

0 commit comments

Comments
 (0)