Karim BELABAS on Fri, 4 Jul 2003 21:36:42 +0200 (MEST)


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: bug in sum() and probably others


On Tue, 1 Jul 2003, Bill Allombert wrote:
> On a x86,
>
> ? sum(i=2^32-10,2^32+10,1)
> %1 = 11

Fixed. [ t_INT not properly updated after (caught) overflow ]

> Looking at the code, it seems there are several bugs
> here.

Indeed. Here's a different one

(21:32) gp > sum(i=-2^32-10,-2^32+10,1)
%1 = 12

[ Fix is independent of the above... ]

> incpos() does not use the t_INT interface

Fixed. I've moved the code to the relevant kernel-specific files.

> and is probably not memory-safe

It is memory safe. These routines increment their argument in place.
They assume that
1) setloop(x) was called before trying to increment x in this way
2) less than 2^64 increments will be required

> and the gerepile() call does not protect a.

No need for this, a is outside the garbage zone.

    Karim.
-- 
Karim Belabas                     Tel: (+33) (0)1 69 15 57 48
Dép. de Mathématiques, Bât. 425   Fax: (+33) (0)1 69 15 60 19
Université Paris-Sud              http://www.math.u-psud.fr/~belabas/
F-91405 Orsay (France)            http://www.parigp-home.de/  [PARI/GP]