@@ -9998,6 +9998,19 @@ ZEND_API bool zend_unary_op_produces_error(uint32_t opcode, const zval *op)
9998
9998
}
9999
9999
return Z_TYPE_P (op ) <= IS_TRUE || !zend_is_op_long_compatible (op );
10000
10000
}
10001
+ /* Can happen when called from zend_optimizer_eval_unary_op() */
10002
+ if (
10003
+ opcode == ZEND_IS_EQUAL
10004
+ || opcode == ZEND_IS_NOT_EQUAL
10005
+ || opcode == ZEND_BOOL
10006
+ || opcode == ZEND_BOOL_NOT
10007
+ ) {
10008
+ /* BW_NOT on string does not convert the string into an integer. */
10009
+ if (Z_TYPE_P (op ) == IS_DOUBLE ) {
10010
+ return true;
10011
+ }
10012
+ return false;
10013
+ }
10001
10014
10002
10015
return 0 ;
10003
10016
}
@@ -10181,7 +10194,7 @@ static void zend_compile_binary_op(znode *result, zend_ast *ast) /* {{{ */
10181
10194
}
10182
10195
10183
10196
do {
10184
- // TODO do not do this for NAN?
10197
+ /* TODO: Do this optimization when other side is not float as NAN will warn and we don't want that
10185
10198
if (opcode == ZEND_IS_EQUAL || opcode == ZEND_IS_NOT_EQUAL) {
10186
10199
if (left_node.op_type == IS_CONST) {
10187
10200
if (Z_TYPE(left_node.u.constant) == IS_FALSE) {
@@ -10204,7 +10217,8 @@ static void zend_compile_binary_op(znode *result, zend_ast *ast) /* {{{ */
10204
10217
break;
10205
10218
}
10206
10219
}
10207
- } else if (opcode == ZEND_IS_IDENTICAL || opcode == ZEND_IS_NOT_IDENTICAL ) {
10220
+ } else */
10221
+ if (opcode == ZEND_IS_IDENTICAL || opcode == ZEND_IS_NOT_IDENTICAL ) {
10208
10222
/* convert $x === null to is_null($x) (i.e. ZEND_TYPE_CHECK opcode). Do the same thing for false/true. (covers IS_NULL, IS_FALSE, and IS_TRUE) */
10209
10223
if (left_node .op_type == IS_CONST ) {
10210
10224
if (Z_TYPE (left_node .u .constant ) <= IS_TRUE && Z_TYPE (left_node .u .constant ) >= IS_NULL ) {
@@ -12011,6 +12025,10 @@ static zend_op *zend_delayed_compile_var(znode *result, zend_ast *ast, uint32_t
12011
12025
12012
12026
bool zend_try_ct_eval_cast (zval * result , uint32_t type , zval * op1 )
12013
12027
{
12028
+ /* NAN warns when casting */
12029
+ if (UNEXPECTED (Z_TYPE_P (op1 ) == IS_DOUBLE && zend_isnan (Z_DVAL_P (op1 )))) {
12030
+ return false;
12031
+ }
12014
12032
switch (type ) {
12015
12033
case _IS_BOOL :
12016
12034
ZVAL_BOOL (result , zval_is_true (op1 ));
0 commit comments