Skip to content

gmp: document the ValueErrors for negative and out of range arguments - #6006

Merged
lacatoire merged 4 commits into
php:masterfrom
qodelicious:gmp-missing-valueerrors
Oct 24, 2026
Merged

lacatoire merged 4 commits into
php:masterfrom
qodelicious:gmp-missing-valueerrors

Conversation

@qodelicious

Copy link
Copy Markdown
Contributor

A bunch of gmp pages didn't say they throw a ValueError for negative or out of range arguments. Added Errors sections to gmp_fact, gmp_pow, gmp_powm (plus the DivisionByZeroError for a zero modulus), gmp_root, gmp_rootrem, gmp_sqrt, gmp_sqrtrem, gmp_strval, gmp_setbit, gmp_clrbit, gmp_scan0 and gmp_scan1, using the same "prior to 8.0.0 a warning was raised" line gmp_binomial has.

gmp_testbit's Errors section still described the old E_WARNING and false, so that's updated. The gmp_pow example also called gmp_pow("2", -1) and said it generates a warning, which throws now, so I took that line out.

Checked against ext/gmp/gmp.c on master, PHP-8.5, PHP-8.0 and PHP-7.4.

Comment thread reference/gmp/functions/gmp-testbit.xml Outdated
Comment thread reference/gmp/functions/gmp-clrbit.xml Outdated
Comment thread reference/gmp/functions/gmp-scan1.xml Outdated
Comment thread reference/gmp/functions/gmp-scan0.xml Outdated
@qodelicious

Copy link
Copy Markdown
Contributor Author

Applied. Thanks.

Comment thread reference/gmp/functions/gmp-powm.xml Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants