Re: com php-src: Fixed bug #73663 ("Invalid opcode 65/16/8" occurs with a variable created with list()): NEWS Zend/tests/bug73663.phpt
Zend/zend_compile.c
| From: | Nikita Popov | Date: | Tue, 06 Dec 2016 11:06:18 +0000 |
| Subject: | Re: com php-src: Fixed bug #73663 ("Invalid opcode 65/16/8" occurs with a variable created with list()): NEWS Zend/tests/bug73663.phpt Zend/zend_compile.c |
||
| References: | 1 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-96208@lists.php.net to get a copy of this message | ||
On Tue, Dec 6, 2016 at 10:32 AM, Xinchen Hui <laruence@php.net> wrote:
> Commit: 358bd77b2360e31324b7d79fc1edf6d45499c68c
> Author: Xinchen Hui <laruence@gmail.com> Tue, 6 Dec 2016
> 17:17:59 +0800
> Parents: 183b4d78aa03bfa4208d00d4e2eec71ffcde4ab7
> Branches: PHP-7.0 PHP-7.1 master
>
> Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=
> 358bd77b2360e31324b7d79fc1edf6d45499c68c
>
> Log:
> Fixed bug #73663 ("Invalid opcode 65/16/8" occurs with a variable created
> with list())
>
> Bugs:
> https://bugs.php.net/73663
>
> Changed paths:
> M NEWS
> A Zend/tests/bug73663.phpt
> M Zend/zend_compile.c
>
>
> Diff:
> diff --git a/NEWS b/NEWS
> index 1bd6df9..901d9f5 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -3,6 +3,8 @@ PHP
> NEWS
> ?? ??? 2016 PHP 7.0.15
>
> - Core:
> + . Fixed bug #73663 ("Invalid opcode 65/16/8" occurs with a variable
> created
> + with list()). (Laruence)
> . Fixed bug #73585 (Logging of "Internal Zend error - Missing class
> information" missing class name). (Laruence)
>
> diff --git a/Zend/tests/bug73663.phpt b/Zend/tests/bug73663.phpt
> new file mode 100644
> index 0000000..66b9a05
> --- /dev/null
> +++ b/Zend/tests/bug73663.phpt
> @@ -0,0 +1,73 @@
> +--TEST--
> +Bug #73663 ("Invalid opcode 65/16/8" occurs with a variable created with
> list())
> +--FILE--
> +<?php
> +function change(&$ref) {
> + $ref = range(1, 10);
> + return;
> +}
> +
> +$func = function (&$ref) {
> + return change($ref);
> +};
> +
> +$array = [1];
> +var_dump(list($val) = $array); // NG: Invalid opcode
> +
> +change(list($val) = $array);
> +var_dump($array);
> +
> +$array = [1];
> +
> +$func(list($val) = $array);
> +var_dump($array);
> +?>
> +--EXPECT--
> +array(1) {
> + [0]=>
> + int(1)
> +}
> +array(10) {
> + [0]=>
> + int(1)
> + [1]=>
> + int(2)
> + [2]=>
> + int(3)
> + [3]=>
> + int(4)
> + [4]=>
> + int(5)
> + [5]=>
> + int(6)
> + [6]=>
> + int(7)
> + [7]=>
> + int(8)
> + [8]=>
> + int(9)
> + [9]=>
> + int(10)
> +}
> +array(10) {
> + [0]=>
> + int(1)
> + [1]=>
> + int(2)
> + [2]=>
> + int(3)
> + [3]=>
> + int(4)
> + [4]=>
> + int(5)
> + [5]=>
> + int(6)
> + [6]=>
> + int(7)
> + [7]=>
> + int(8)
> + [8]=>
> + int(9)
> + [9]=>
> + int(10)
> +}
> diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
> index ca6b7f2..4b7b997 100644
> --- a/Zend/zend_compile.c
> +++ b/Zend/zend_compile.c
> @@ -2781,12 +2781,21 @@ uint32_t zend_compile_args(zend_ast *ast,
> zend_function *fbc) /* {{{ */
> }
> } else {
> zend_compile_expr(&arg_node, arg);
> - ZEND_ASSERT(arg_node.op_type != IS_CV);
> if (arg_node.op_type == IS_VAR) {
> opcode = ZEND_SEND_VAR_NO_REF;
> if (fbc && ARG_MUST_BE_SENT_BY_REF(fbc,
> arg_num)) {
> flags |= ZEND_ARG_SEND_BY_REF;
> }
> + } else if (arg_node.op_type == IS_CV) {
> + if (fbc) {
> + if (ARG_SHOULD_BE_SENT_BY_REF(fbc,
> arg_num)) {
> + opcode = ZEND_SEND_REF;
>
I think per our usual convention the return value of an assignment is not
an lvalue, so we should use SEND_VAR_NO_REF rather than SEND_REF here.
Nikita
> + } else {
> + opcode = ZEND_SEND_VAR;
> + }
> + } else {
> + opcode = ZEND_SEND_VAR_EX;
> + }
> } else {
> if (fbc) {
> opcode = ZEND_SEND_VAL;
>
>
> --
> PHP CVS Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>