bug in gmp_printf (?)

Marc Glisse marc.glisse at inria.fr
Wed Aug 17 23:44:03 CEST 2011


On Wed, 17 Aug 2011, Torbjorn Granlund wrote:

>  test=doprntf.c:128 GNU MP assertion failed: (p-)conv == 1 && p->prec ...
>
> I would be grateful if some other GMP developer could help with this.
> The bug is for real, to reproduce configure with --enable-assert.  I
> haven't analysed if the ASSERT is wrong, or if it is a more serious
> issue.
>
> All relevant code is a few lines in printf/doprntf.c.

The code has 2 cases: f<1 and f>=1. To print a number <1, it assumes it 
will write something like .0000xxx (nothing before the dot). Except that 
rounding may turn a number <1 into exactly 1. But since you are only 
writing "1" in that case, it seems you always have enough space for that.

Assuming that is indeed what is going on (I really didn't check deep 
enough), I'm not sure what to do, maybe add a comment and add a || check 
for s "1" and exp 1.

-- 
Marc Glisse


More information about the gmp-bugs mailing list