GMP compile failure
Tim Hockin
thockin at hockin.org
Fri Dec 28 21:38:50 CET 2007
This (simplified) C++ snippet does not compile. But it doesn't give
me the possibly-expected undefined operator error:
mpz_class foo(123);
mpz_class bar = foo & 0x107;
I get:
/usr/include/gmpxx.h: In member function 'void
__gmp_expr<__gmpz_value, __gmp_binary_expr<__gmp_expr<__gmpz_value,
__gmpz_value>, T, Op> >::eval(__mpz_struct*)
const [with T = long int, Op = __gmp_binary_and]':
/usr/include/gmpxx.h:3066: instantiated from 'void
__gmp_set_expr(__mpz_struct *, const __gmp_expr<__gmpz_value, T>&)
[with T = __gmp_binary_expr<__gmp_expr<__gmpz_value, __gmpz_value>,
long int, __gmp_binary_and>]'
/usr/include/gmpxx.h:2282: instantiated from
'__gmp_expr<__gmpz_value, __gmpz_value>::__gmp_expr(const
__gmp_expr<T, U>&) [with T = __gmpz_value, U =
__gmp_binary_expr<__gmp_expr<__gmpz_value, __gmpz_value>, long int,
__gmp_binary_and>]'
bignum_test.cpp:788: instantiated from here
/usr/include/gmpxx.h:3413: error: invalid conversion from 'const long
int' to 'const __mpz_struct*'
/usr/include/gmpxx.h:3413: error: initializing argument 3 of 'static
void __gmp_binary_and::eval(__mpz_struct*, const __mpz_struct*, const
__mpz_struct*)'
make: *** [bignum_test.o] Error 1
I can make it build by explicitly casting the int to mpz_class, but
that's kind of a pain. I am converting a codebase to use GMP, and
this is causing lots of errors.
Is there any answer to this, other than "cast it"? If not, why such a
cryptic error?
Thanks
Tim
p.s. I'm not on this list, if you wouldn't mind CC:ing me.
More information about the gmp-discuss
mailing list