diff options
-rw-r--r-- | gmpxx.h | 11 | ||||
-rw-r--r-- | tests/cxx/t-ops2qf.cc | 2 |
2 files changed, 9 insertions, 4 deletions
@@ -1,6 +1,7 @@ /* gmpxx.h -- C++ class wrapper for GMP types. -*- C++ -*- -Copyright 2001-2003, 2006, 2008, 2011-2015 Free Software Foundation, Inc. +Copyright 2001-2003, 2006, 2008, 2011-2015, 2018 Free Software +Foundation, Inc. This file is part of the GNU MP Library. @@ -981,11 +982,15 @@ struct __gmp_binary_equal { return mpq_equal(q, r) != 0; } static bool eval(mpq_srcptr q, unsigned long int l) - { return mpz_cmp_ui(mpq_denref(q), 1) == 0 && mpz_cmp_ui(mpq_numref(q), l) == 0; } + { return ((__GMPXX_CONSTANT(l) && l == 0) || + mpz_cmp_ui(mpq_denref(q), 1) == 0) && + mpz_cmp_ui(mpq_numref(q), l) == 0; } static bool eval(unsigned long int l, mpq_srcptr q) { return eval(q, l); } static bool eval(mpq_srcptr q, signed long int l) - { return mpz_cmp_ui(mpq_denref(q), 1) == 0 && mpz_cmp_si(mpq_numref(q), l) == 0; } + { return ((__GMPXX_CONSTANT(l) && l == 0) || + mpz_cmp_ui(mpq_denref(q), 1) == 0) && + mpz_cmp_si(mpq_numref(q), l) == 0; } static bool eval(signed long int l, mpq_srcptr q) { return eval(q, l); } static bool eval(mpq_srcptr q, double d) diff --git a/tests/cxx/t-ops2qf.cc b/tests/cxx/t-ops2qf.cc index f3ba3ad81..bd96f61a3 100644 --- a/tests/cxx/t-ops2qf.cc +++ b/tests/cxx/t-ops2qf.cc @@ -1,6 +1,6 @@ /* Test mp*_class operators and functions. -Copyright 2011, 2012 Free Software Foundation, Inc. +Copyright 2011, 2012, 2018 Free Software Foundation, Inc. This file is part of the GNU MP Library test suite. |