cvs: ZendEngine2 / zend_vm_def.h zend_vm_execute.h zend_vm_opcodes.h /tests bug33257.phpt

From: Date: Mon, 19 Sep 2005 16:01:58 +0000
Subject: cvs: ZendEngine2 / zend_vm_def.h zend_vm_execute.h zend_vm_opcodes.h /tests bug33257.phpt
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-4142@lists.php.net to get a copy of this message
dmitry Mon Sep 19 12:01:58 2005 EDT Modified files: /ZendEngine2 zend_vm_def.h zend_vm_execute.h zend_vm_opcodes.h /ZendEngine2/tests bug33257.phpt Log: Fixed parameter passing incompatibilities. Now it is possible to call array_pop(explode("&","1&2&3")) again.

http://cvs.php.net/diff.php/ZendEngine2/zend_vm_def.h?r1=1.73&r2=1.74&ty=u Index: ZendEngine2/zend_vm_def.h diff -u ZendEngine2/zend_vm_def.h:1.73 ZendEngine2/zend_vm_def.h:1.74 --- ZendEngine2/zend_vm_def.h:1.73 Fri Sep 16 11:24:08 2005 +++ ZendEngine2/zend_vm_def.h Mon Sep 19 12:01:53 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_def.h,v 1.73 2005/09/16 15:24:08 dmitry Exp $ */ +/* $Id: zend_vm_def.h,v 1.74 2005/09/19 16:01:53 dmitry Exp $ */ /* If you change this file, please regenerate the zend_vm_execute.h and * zend_vm_opcodes.h files by running: @@ -2224,6 +2224,9 @@ ZEND_VM_HANDLER(106, ZEND_SEND_VAR_NO_REF, VAR|CV, ANY) { zend_op *opline = EX(opline); + zend_free_op free_op1; + zval *varptr; + if (opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) { /* Had function_ptr at compile_time */ if (!(opline->extended_value & ZEND_ARG_SEND_BY_REF)) { ZEND_VM_DISPATCH_TO_HELPER(zend_send_by_var_helper); @@ -2231,23 +2234,27 @@ } else if (!ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->op2.u.opline_num)) { ZEND_VM_DISPATCH_TO_HELPER(zend_send_by_var_helper); } - if ((opline->extended_value & ZEND_ARG_SEND_FUNCTION) && - !EX_T(opline->op1.u.var).var.fcall_returned_reference) { - zend_error_noreturn(E_ERROR, "Only variables can be passed by reference"); + + varptr = GET_OP1_ZVAL_PTR(BP_VAR_R); + if ((!(opline->extended_value & ZEND_ARG_SEND_FUNCTION) || + EX_T(opline->op1.u.var).var.fcall_returned_reference) && + varptr != &EG(uninitialized_zval) && + (PZVAL_IS_REF(varptr) || varptr->refcount == 1)) { + varptr->is_ref = 1; + varptr->refcount++; + zend_ptr_stack_push(&EG(argument_stack), varptr); } else { - zval *varptr; - zend_free_op free_op1; - varptr = GET_OP1_ZVAL_PTR(BP_VAR_R); + zval *valptr; - if (varptr != &EG(uninitialized_zval) && (PZVAL_IS_REF(varptr) || varptr->refcount == 1)) { - varptr->is_ref = 1; - varptr->refcount++; - zend_ptr_stack_push(&EG(argument_stack), varptr); - FREE_OP1_IF_VAR(); - ZEND_VM_NEXT_OPCODE(); + zend_error(E_STRICT, "Only variables should be passed by reference"); + ALLOC_ZVAL(valptr); + INIT_PZVAL_COPY(valptr, varptr); + if (!IS_OP1_TMP_FREE()) { + zval_copy_ctor(valptr); } - zend_error_noreturn(E_ERROR, "Only variables can be passed by reference"); + zend_ptr_stack_push(&EG(argument_stack), valptr); } + FREE_OP1_IF_VAR(); ZEND_VM_NEXT_OPCODE(); } http://cvs.php.net/diff.php/ZendEngine2/zend_vm_execute.h?r1=1.76&r2=1.77&ty=u Index: ZendEngine2/zend_vm_execute.h diff -u ZendEngine2/zend_vm_execute.h:1.76 ZendEngine2/zend_vm_execute.h:1.77 --- ZendEngine2/zend_vm_execute.h:1.76 Fri Sep 16 11:24:08 2005 +++ ZendEngine2/zend_vm_execute.h Mon Sep 19 12:01:53 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_execute.h,v 1.76 2005/09/16 15:24:08 dmitry Exp $ */ +/* $Id: zend_vm_execute.h,v 1.77 2005/09/19 16:01:53 dmitry Exp $ */ static opcode_handler_t zend_user_opcode_handlers[256] = {(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL}; @@ -7331,6 +7331,9 @@ static int ZEND_SEND_VAR_NO_REF_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { zend_op *opline = EX(opline); + zend_free_op free_op1; + zval *varptr; + if (opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) { /* Had function_ptr at compile_time */ if (!(opline->extended_value & ZEND_ARG_SEND_BY_REF)) { return zend_send_by_var_helper_SPEC_VAR(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); @@ -7338,23 +7341,27 @@ } else if (!ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->op2.u.opline_num)) { return zend_send_by_var_helper_SPEC_VAR(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } - if ((opline->extended_value & ZEND_ARG_SEND_FUNCTION) && - !EX_T(opline->op1.u.var).var.fcall_returned_reference) { - zend_error_noreturn(E_ERROR, "Only variables can be passed by reference"); + + varptr = _get_zval_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC); + if ((!(opline->extended_value & ZEND_ARG_SEND_FUNCTION) || + EX_T(opline->op1.u.var).var.fcall_returned_reference) && + varptr != &EG(uninitialized_zval) && + (PZVAL_IS_REF(varptr) || varptr->refcount == 1)) { + varptr->is_ref = 1; + varptr->refcount++; + zend_ptr_stack_push(&EG(argument_stack), varptr); } else { - zval *varptr; - zend_free_op free_op1; - varptr = _get_zval_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC); + zval *valptr; - if (varptr != &EG(uninitialized_zval) && (PZVAL_IS_REF(varptr) || varptr->refcount == 1)) { - varptr->is_ref = 1; - varptr->refcount++; - zend_ptr_stack_push(&EG(argument_stack), varptr); - if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; - ZEND_VM_NEXT_OPCODE(); + zend_error(E_STRICT, "Only variables should be passed by reference"); + ALLOC_ZVAL(valptr); + INIT_PZVAL_COPY(valptr, varptr); + if (!0) { + zval_copy_ctor(valptr); } - zend_error_noreturn(E_ERROR, "Only variables can be passed by reference"); + zend_ptr_stack_push(&EG(argument_stack), valptr); } + if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; ZEND_VM_NEXT_OPCODE(); } @@ -20097,6 +20104,9 @@ static int ZEND_SEND_VAR_NO_REF_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { zend_op *opline = EX(opline); + + zval *varptr; + if (opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) { /* Had function_ptr at compile_time */ if (!(opline->extended_value & ZEND_ARG_SEND_BY_REF)) { return zend_send_by_var_helper_SPEC_CV(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); @@ -20104,23 +20114,27 @@ } else if (!ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->op2.u.opline_num)) { return zend_send_by_var_helper_SPEC_CV(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } - if ((opline->extended_value & ZEND_ARG_SEND_FUNCTION) && - !EX_T(opline->op1.u.var).var.fcall_returned_reference) { - zend_error_noreturn(E_ERROR, "Only variables can be passed by reference"); - } else { - zval *varptr; - - varptr = _get_zval_ptr_cv(&opline->op1, EX(Ts), BP_VAR_R TSRMLS_CC); - if (varptr != &EG(uninitialized_zval) && (PZVAL_IS_REF(varptr) || varptr->refcount == 1)) { - varptr->is_ref = 1; - varptr->refcount++; - zend_ptr_stack_push(&EG(argument_stack), varptr); + varptr = _get_zval_ptr_cv(&opline->op1, EX(Ts), BP_VAR_R TSRMLS_CC); + if ((!(opline->extended_value & ZEND_ARG_SEND_FUNCTION) || + EX_T(opline->op1.u.var).var.fcall_returned_reference) && + varptr != &EG(uninitialized_zval) && + (PZVAL_IS_REF(varptr) || varptr->refcount == 1)) { + varptr->is_ref = 1; + varptr->refcount++; + zend_ptr_stack_push(&EG(argument_stack), varptr); + } else { + zval *valptr; - ZEND_VM_NEXT_OPCODE(); + zend_error(E_STRICT, "Only variables should be passed by reference"); + ALLOC_ZVAL(valptr); + INIT_PZVAL_COPY(valptr, varptr); + if (!0) { + zval_copy_ctor(valptr); } - zend_error_noreturn(E_ERROR, "Only variables can be passed by reference"); + zend_ptr_stack_push(&EG(argument_stack), valptr); } + ZEND_VM_NEXT_OPCODE(); } http://cvs.php.net/diff.php/ZendEngine2/zend_vm_opcodes.h?r1=1.53&r2=1.54&ty=u Index: ZendEngine2/zend_vm_opcodes.h diff -u ZendEngine2/zend_vm_opcodes.h:1.53 ZendEngine2/zend_vm_opcodes.h:1.54 --- ZendEngine2/zend_vm_opcodes.h:1.53 Fri Sep 16 11:24:09 2005 +++ ZendEngine2/zend_vm_opcodes.h Mon Sep 19 12:01:55 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_opcodes.h,v 1.53 2005/09/16 15:24:09 dmitry Exp $ */ +/* $Id: zend_vm_opcodes.h,v 1.54 2005/09/19 16:01:55 dmitry Exp $ */ #define ZEND_NOP 0 #define ZEND_ADD 1 http://cvs.php.net/diff.php/ZendEngine2/tests/bug33257.phpt?r1=1.2&r2=1.3&ty=u Index: ZendEngine2/tests/bug33257.phpt diff -u ZendEngine2/tests/bug33257.phpt:1.2 ZendEngine2/tests/bug33257.phpt:1.3 --- ZendEngine2/tests/bug33257.phpt:1.2 Wed Jun 22 04:33:00 2005 +++ ZendEngine2/tests/bug33257.phpt Mon Sep 19 12:01:56 2005 @@ -14,4 +14,10 @@ print_r(X::getArr()); ?> --EXPECTF-- -Fatal error: Only variables can be passed by reference in %sbug33257.php on line 10 +Strict Standards: Only variables should be passed by reference in %sbug33257.php on line 10 +Array +( + [0] => a + [1] => b + [2] => c +)
« previous php.zend-engine.cvs (#4142) next »