diff options
author | Marc Glisse <marc.glisse@inria.fr> | 2012-05-31 23:31:48 +0200 |
---|---|---|
committer | Marc Glisse <marc.glisse@inria.fr> | 2012-05-31 23:31:48 +0200 |
commit | d16b005b490eabeda823c3fb00fef9329a4cf649 (patch) | |
tree | 16a94165cc18e9e147686b0232a9c056eca7bf08 /gmpxx.h | |
parent | 024f07177c7e393e9ea0ab804998ec12408bd74d (diff) | |
download | gmp-d16b005b490eabeda823c3fb00fef9329a4cf649.tar.gz |
Handle mpq_class(0,1)
Diffstat (limited to 'gmpxx.h')
-rw-r--r-- | gmpxx.h | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -1641,7 +1641,14 @@ public: explicit __gmp_expr(const char *s, int base = 0) { mpq_init (mp); - if (mpq_set_str(mp, s, base) != 0) + // If s is the literal 0, we meant to call another constructor. + // If s just happens to evaluate to 0, we would crash, so whatever. + if (s == 0) + { + // Don't turn mpq_class(0,0) into 0 + mpz_set_si(mpq_denref(mp), base); + } + else if (mpq_set_str(mp, s, base) != 0) { mpq_clear (mp); throw std::invalid_argument ("mpq_set_str"); |