[PPL-devel] Bug affecting mpq_class::get_num() and mpq_class::get_den()?

Roberto Bagnara bagnara at cs.unipr.it
Sat Jun 8 11:43:57 CEST 2002


Hi there,

I believe the snippet following the signature shows a bug that is present
in both GMP 4.0.1 and GMP 4.1.
Please let me know if any workaround is possible.
All the best

     Roberto

-- 
Prof. Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:bagnara at cs.unipr.it


/*
The GMP 4.x documentation says:

   mpz_class& mpq_class::get_num ()
   mpz_class& mpq_class::get_den ()

   Get a reference to an `mpz_class' which is the numerator or
   denominator of an `mpq_class'.  This can be used both for read and
   write access.  If the object returned is modified, it modifies the
   original `mpq_class'.


However, the following simple wrapper, gives, with GCC 3.0.4

$ g++ -W -Wall -c gmpbug.cc
gmpbug.cc: In function `mpz_class& numerator(mpq_class&)':
gmpbug.cc:24: could not convert `__gmp_expr<__gmpq_value,
    __gmpq_value>::get_num()' to `mpz_class&'
*/

#include <gmpxx.h>

mpz_class&
numerator(mpq_class& r) {
   return r.get_num();
}




More information about the PPL-devel mailing list