Skip to content

Conversation

@nielsdos
Copy link
Member

ZEND_THREEWAY_COMPARE evaluates its operands multiple times.

ZEND_THREEWAY_COMPARE evaluates its operands multiple times.

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.

@nielsdos nielsdos merged commit a142f10 into php:master Apr 14, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants