Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions ext/gmp/gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,8 @@ static int gmp_compare(zval *op1, zval *op2) /* {{{ */
return ZEND_UNCOMPARABLE;
}

return ZEND_THREEWAY_COMPARE(mpz_cmp(gmp_op1, gmp_op2), 0);
int ret = mpz_cmp(gmp_op1, gmp_op2); /* avoid multiple evaluations */
return ZEND_THREEWAY_COMPARE(ret, 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it somehow possible to put this into the macro itself?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not without relying on non-portable GCC extensions.

}
/* }}} */

Expand Down Expand Up @@ -1422,7 +1423,8 @@ ZEND_FUNCTION(gmp_cmp)
GMP_Z_PARAM_INTO_MPZ_PTR(gmpnum_b)
ZEND_PARSE_PARAMETERS_END();

RETURN_LONG(ZEND_THREEWAY_COMPARE(mpz_cmp(gmpnum_a, gmpnum_b), 0));
int ret = mpz_cmp(gmpnum_a, gmpnum_b); /* avoid multiple evaluations */
RETURN_LONG(ZEND_THREEWAY_COMPARE(ret, 0));
}
/* }}} */

Expand Down
Loading