Re: overflow in mpz type with a simple mpz_add_ui

2020-09-21 Thread Vincent Lefevre
On 2020-09-21 21:17:36 +0200, Torbjorn Granlund wrote: > Vincent Lefevre writes: > > This is not properly documented, then. The manual says: > >'mpz_add_ui', 'mpz_sub_ui', 'mpf_add_ui' and 'mpf_sub_ui' benefit >from an in-place operation like 'mpz_add_ui(x,x,y)', since usually

Re: overflow in mpz type with a simple mpz_add_ui

2020-09-21 Thread Torbjörn Granlund
Vincent Lefevre writes: This is not properly documented, then. The manual says: 'mpz_add_ui', 'mpz_sub_ui', 'mpf_add_ui' and 'mpf_sub_ui' benefit from an in-place operation like 'mpz_add_ui(x,x,y)', since usually ^^ only one or two limbs of

Re: overflow in mpz type with a simple mpz_add_ui

2020-09-21 Thread Vincent Lefevre
On 2020-09-21 18:16:15 +0200, Torbjorn Granlund wrote: > Vincent Lefevre writes: > > So the overflow occurs in "mpz_add_ui (z, z, 1);", though this > operation doesn't need a larger mpz_t and could even be done > in place: no carry occurs here, and note that a carry for a > huge number

Re: overflow in mpz type with a simple mpz_add_ui

2020-09-21 Thread Marco Bodrato
Ciao, Il 2020-09-21 18:16 t...@gmplib.org ha scritto: overflow. The overflow detection flags some false positives, which is by design. But maybe we could avoid the false positive at least for the following example: #include #include "gmp.h" int main (void) { mpz_t z; mpz_init (z);

Re: overflow in mpz type with a simple mpz_add_ui

2020-09-21 Thread Torbjörn Granlund
Vincent Lefevre writes: So the overflow occurs in "mpz_add_ui (z, z, 1);", though this operation doesn't need a larger mpz_t and could even be done in place: no carry occurs here, and note that a carry for a huge number is very unlikely to occur. No bug. You're (presumably

overflow in mpz type with a simple mpz_add_ui

2020-09-21 Thread Vincent Lefevre
With GMP 6.2.0 (Debian's package libgmp10:i386) on x86_64 in the 32-bit ABI, i.e. when compiling with -m32, I get the following error: cventin:~> cat tst.c #include #include int main (void) { mpz_t z; mpz_init_set_ui (z, 17); mpz_mul_2exp (z, z, 0xffbc); printf ("OK\n");