GMP: Gracefully handle more overflows. (#51243)
Fixes https://github.com/JuliaLang/julia/issues/8286, which regressed
due to a GMP upgrade in https://github.com/JuliaLang/julia/pull/45375.
(cherry picked from commit 10974814b3faa1dea140062cfe1f3e63962074d5)