pointers vs arrays

Marc Glisse marc.glisse at inria.fr
Wed Jun 9 18:29:35 UTC 2021

On Wed, 9 Jun 2021, Marco Bodrato wrote:
> Il 2021-05-12 15:17 Marc Glisse ha scritto:
>> the latest version of gcc has a new (questionable) warning that
>> complains if a function is declared as taking a mpz_t parameter and
>> redeclared as taking mpz_ptr, or the reverse.
>> We might as well be consistent and use pointers everywhere, as in the
>> attached patch. Does someone disagree?
> Maybe this will move the warnings on the users side :-/

Maybe, but only if people redeclare the GMP functions themselves in 
addition to including gmp.h, which looks like a strange idea.

I wondered about using gmp_randstate_t instead of gmp_randstate_ptr to 
avoid changing gmp.h, but that would not be consistent with mpz_t, etc. Or 
maybe change all prototypes to use mpz_t instead of mpz_ptr...

To me, the most sensible option for users remains disabling this warning 

> By the way, I think that also the documentation should be updated 
> accordingly.

We have never documented mpz_ptr/mpz_srcptr, my patch does not change this 
discrepancy. Maybe this is a new motivation to document it, but that seems 
like a lot of boring work...

Marc Glisse

More information about the gmp-devel mailing list