[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#12350: Composites identified as primes in factor.c (when HAVE_GMP)
From: |
Jim Meyering |
Subject: |
bug#12350: Composites identified as primes in factor.c (when HAVE_GMP) |
Date: |
Tue, 09 Oct 2012 14:26:55 +0200 |
Pádraig Brady wrote:
> On 10/08/2012 03:47 PM, Pádraig Brady wrote:
>> diff --git a/src/factor.c b/src/factor.c
>> index 5bfbfdc..843542b 100644
>> --- a/src/factor.c
>> +++ b/src/factor.c
>> @@ -526,6 +526,29 @@ factor_insert_large (struct factors *factors,
>> }
>>
>> #if HAVE_GMP
>> +
>> +# if !HAVE_DECL_MPZ_INITS
>> +
>> +# define mpz_inits(...) mpz_va_init (mpz_init, __VA_ARGS__)
>> +# define mpz_clears(...) mpz_va_init (mpz_clear, __VA_ARGS__)
>> +
>> +static void
>> +mpz_va_init (void (*mpz_single_init)(mpz_t), mpz_ptr mpz, ...)
>> +{
>> + va_list ap;
>> +
>> + va_start (ap, mpz);
>> +
>> + while (mpz != NULL)
>> + {
>> + mpz_single_init (mpz);
>> + mpz = va_arg (ap, mpz_ptr);
>> + }
>> +
>> + va_end (ap);
>> +}
>> +# endif
>> +
>> static void mp_factor (mpz_t, struct mp_factors *);
>
> Actually the above doesn't order the va_arg() call correctly.
> Also it uses mpz_ptr which is not kosher it seems:
> http://gmplib.org/list-archives/gmp-discuss/2009-May/003769.html
> So I've adjusted to:
>
> #define mpz_inits(...) mpz_va_init (mpz_init, __VA_ARGS__)
> #define mpz_clears(...) mpz_va_init (mpz_clear, __VA_ARGS__)
>
> static void
> mpz_va_init (void (*mpz_single_init)(mpz_t), ...)
> {
> va_list ap;
>
> va_start (ap, mpz_single_init);
>
> mpz_t *mpz;
> while ((mpz = va_arg (ap, mpz_t *)))
> mpz_single_init (*mpz);
>
> va_end (ap);
> }
Oh! Were there symptoms?
Ship it :-)
- bug#12350: Composites identified as primes in factor.c (when HAVE_GMP), Pádraig Brady, 2012/10/08
- bug#12350: Composites identified as primes in factor.c (when HAVE_GMP), Torbjorn Granlund, 2012/10/08
- bug#12350: Composites identified as primes in factor.c (when HAVE_GMP), Jim Meyering, 2012/10/08
- bug#12350: Composites identified as primes in factor.c (when HAVE_GMP), Pádraig Brady, 2012/10/08
- bug#12350: Composites identified as primes in factor.c (when HAVE_GMP), Torbjorn Granlund, 2012/10/08
- bug#12350: Composites identified as primes in factor.c (when HAVE_GMP), Jim Meyering, 2012/10/08
- bug#12350: Composites identified as primes in factor.c (when HAVE_GMP), Torbjorn Granlund, 2012/10/08
- bug#12350: Composites identified as primes in factor.c (when HAVE_GMP), Pádraig Brady, 2012/10/08
bug#12350: Composites identified as primes in factor.c (when HAVE_GMP), Philipp Thomas, 2012/10/17