Correctly handle errors in GMP comparison