Skip to content

Commit 8a673e9

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fixed incorrect usage of QM_ASSIGN instruction
2 parents cf4c4ee + e45a757 commit 8a673e9

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

Zend/tests/bug73663.phpt

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,8 @@ var_dump($array);
2020
$array = [1];
2121
$func(list(&$val) = $array);
2222
var_dump($array);
23-
24-
$array = [1];
25-
change(list($val) = $array);
26-
var_dump($array);
2723
?>
28-
--EXPECTF--
24+
--EXPECT--
2925
array(1) {
3026
[0]=>
3127
int(1)
@@ -74,9 +70,3 @@ array(10) {
7470
[9]=>
7571
int(10)
7672
}
77-
78-
Notice: Only variables should be passed by reference in %s on line %d
79-
array(1) {
80-
[0]=>
81-
int(1)
82-
}

Zend/tests/bug73663_2.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Bug #73663.2 ("Invalid opcode 65/16/8" occurs with a variable created with list())
3+
--FILE--
4+
<?php
5+
function change(&$ref) {
6+
$ref = range(1, 10);
7+
return;
8+
}
9+
10+
$array = [1];
11+
change(list($val) = $array);
12+
var_dump($array);
13+
?>
14+
--EXPECTF--
15+
Fatal error: Only variables can be passed by reference in %s on line %d

Zend/zend_compile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2738,7 +2738,7 @@ void zend_compile_assign(znode *result, zend_ast *ast) /* {{{ */
27382738
if (zend_try_compile_cv(&cv_node, expr_ast) == FAILURE) {
27392739
zend_compile_simple_var_no_cv(&expr_node, expr_ast, BP_VAR_R, 0);
27402740
} else {
2741-
zend_emit_op(&expr_node, ZEND_QM_ASSIGN, &cv_node, NULL);
2741+
zend_emit_op_tmp(&expr_node, ZEND_QM_ASSIGN, &cv_node, NULL);
27422742
}
27432743
} else {
27442744
zend_compile_expr(&expr_node, expr_ast);
@@ -2778,7 +2778,7 @@ void zend_compile_assign(znode *result, zend_ast *ast) /* {{{ */
27782778
if (zend_try_compile_cv(&cv_node, expr_ast) == FAILURE) {
27792779
zend_compile_simple_var_no_cv(&expr_node, expr_ast, BP_VAR_R, 0);
27802780
} else {
2781-
zend_emit_op(&expr_node, ZEND_QM_ASSIGN, &cv_node, NULL);
2781+
zend_emit_op_tmp(&expr_node, ZEND_QM_ASSIGN, &cv_node, NULL);
27822782
}
27832783
} else {
27842784
zend_compile_expr(&expr_node, expr_ast);

0 commit comments

Comments
 (0)