diff options
author | Dmitry Stogov <dmitry@zend.com> | 2015-04-06 14:30:05 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2015-04-06 14:30:05 +0300 |
commit | cae0147ed3ceb55fcb1bc059b8e8ea6a36ea69a8 (patch) | |
tree | 4ca16379ac8d5cab749f07747e2599ee23a4d175 /Zend/zend_operators.h | |
parent | caf9219dea58dcc6ef6da2b3b86a1e9808363bff (diff) | |
download | php-git-cae0147ed3ceb55fcb1bc059b8e8ea6a36ea69a8.tar.gz |
Fixed weird operators behavior. Division by zero now emits warning and returns +/-INF, modulo by zero and intdid() throws an exception, shifts by negative offset throw exceptions. Compile-time evaluation of division by zero is disabled.
Diffstat (limited to 'Zend/zend_operators.h')
-rw-r--r-- | Zend/zend_operators.h | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 9e937eba3b..2625cda27f 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -775,52 +775,6 @@ static zend_always_inline void fast_long_sub_function(zval *result, zval *op1, z static zend_always_inline int fast_div_function(zval *result, zval *op1, zval *op2) { -#if 0 - if (EXPECTED(Z_TYPE_P(op1) == IS_LONG) && 0) { - if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { - if (UNEXPECTED(Z_LVAL_P(op2) == 0)) { - zend_error(E_WARNING, "Division by zero"); - ZVAL_BOOL(result, 0); - return FAILURE; - } else if (UNEXPECTED(Z_LVAL_P(op2) == -1 && Z_LVAL_P(op1) == ZEND_LONG_MIN)) { - /* Prevent overflow error/crash */ - ZVAL_DOUBLE(result, (double) ZEND_LONG_MIN / -1); - } else if (EXPECTED(Z_LVAL_P(op1) % Z_LVAL_P(op2) == 0)) { - /* integer */ - ZVAL_LONG(result, Z_LVAL_P(op1) / Z_LVAL_P(op2)); - } else { - ZVAL_DOUBLE(result, ((double) Z_LVAL_P(op1)) / ((double)Z_LVAL_P(op2))); - } - return SUCCESS; - } else if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) { - if (UNEXPECTED(Z_DVAL_P(op2) == 0)) { - zend_error(E_WARNING, "Division by zero"); - ZVAL_BOOL(result, 0); - return FAILURE; - } - ZVAL_DOUBLE(result, ((double)Z_LVAL_P(op1)) / Z_DVAL_P(op2)); - return SUCCESS; - } - } else if (EXPECTED(Z_TYPE_P(op1) == IS_DOUBLE) && 0) { - if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) { - if (UNEXPECTED(Z_DVAL_P(op2) == 0)) { - zend_error(E_WARNING, "Division by zero"); - ZVAL_BOOL(result, 0); - return FAILURE; - } - ZVAL_DOUBLE(result, Z_DVAL_P(op1) / Z_DVAL_P(op2)); - return SUCCESS; - } else if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { - if (UNEXPECTED(Z_LVAL_P(op2) == 0)) { - zend_error(E_WARNING, "Division by zero"); - ZVAL_BOOL(result, 0); - return FAILURE; - } - ZVAL_DOUBLE(result, Z_DVAL_P(op1) / ((double)Z_LVAL_P(op2))); - return SUCCESS; - } - } -#endif return div_function(result, op1, op2); } |