undefined behavior in GMP 5.1.2
Vincent Lefevre
vincent at vinc17.net
Sat Sep 21 10:53:43 CEST 2013
On 2013-09-21 09:08:55 +0200, Marc Glisse wrote:
> On Sat, 21 Sep 2013, Torbjorn Granlund wrote:
>
> >Vincent Lefevre <vincent at vinc17.net> writes:
> >
> > I haven't tried: the "make check" stopped early because of these
> > two failures.
> >
> >make -k?
>
> That and getting rid of -fno-sanitize-recover. Seriously, you asked it to
> stop...
OK for "make -k", but -fno-sanitize-recover makes it more clear
which tests are affected with the latest Automake versions, and
also avoids a lot of potential output.
I get the following warnings for tests/mpn/t-mulmid.c:
t-mulmid.c:81:11: warning: format specifies type 'int' but the argument has type 'mp_size_t' (aka 'long') [-Wformat]
test, an, bn, rn);
^~
t-mulmid.c:81:15: warning: format specifies type 'int' but the argument has type 'mp_size_t' (aka 'long') [-Wformat]
test, an, bn, rn);
^~
t-mulmid.c:81:19: warning: format specifies type 'int' but the argument has type 'mp_size_t' (aka 'long') [-Wformat]
test, an, bn, rn);
^~
for
printf ("ERROR in test %d, an = %d, bn = %d, rn = %d\n",
test, an, bn, rn);
This is really a bug.
In tests/mpz/t-mfac_uiui.c, this is a potential bug (replace & by %
I suppose):
t-mfac_uiui.c:69:55: warning: data argument not used by format string [-Wformat-extra-args]
printf ("mpz_mfac_uiui(%lu,&i) wrong\n", n, MULTIFAC_WHEEL);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
t-mfac_uiui.c:34:24: note: expanded from macro 'MULTIFAC_WHEEL'
#define MULTIFAC_WHEEL (2*3*11)
^
t-mfac_uiui.c:78:55: warning: data argument not used by format string [-Wformat-extra-args]
printf ("mpz_mfac_uiui(%lu,&i) wrong\n", n, MULTIFAC_WHEEL2);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
t-mfac_uiui.c:35:25: note: expanded from macro 'MULTIFAC_WHEEL2'
#define MULTIFAC_WHEEL2 (5*13)
^
In mpz:
get_str.c:538:52: runtime error: index -1 out of bounds for type 'powers_t [64]'
FAIL: convert
get_str.c:538:52: runtime error: index -1 out of bounds for type 'powers_t [64]'
FAIL: io
kronzs.c:53:28: runtime error: negation of -9223372036854775808 cannot be represented in type 'long'; cast to an unsigned type to negate this value to itself
FAIL: t-jac
get_d.c:137:7: runtime error: signed integer overflow: 9223372036854775807 - -2 cannot be represented in type 'long'
FAIL: t-get_d_2exp
(same bug as already reported)
In mpq:
get_d.c:137:7: runtime error: signed integer overflow: 9223372036854775807 - -320 cannot be represented in type 'long'
FAIL: t-get_d
(ditto)
In mpf:
mul.c:81:31: runtime error: signed integer overflow: -5260204364771764878 + -5260204364771764878 cannot be represented in type 'long'
FAIL: reuse
get_d.c:137:7: runtime error: signed integer overflow: 9223372036854775807 - -1088 cannot be represented in type 'long'
FAIL: t-get_d
get_d.c:137:7: runtime error: signed integer overflow: 9223372036854775807 - -64 cannot be represented in type 'long'
FAIL: t-get_d_2exp
(ditto for the last two)
In rand:
t-urbui.c:38:19: runtime error: left shift of 1 by 63 places cannot be represented in type 'long'
FAIL: t-urbui
In misc:
get_d.c:137:7: runtime error: signed integer overflow: 9223372036854775807 - -384 cannot be represented in type 'long'
FAIL: t-printf
(ditto)
--
Vincent Lefèvre <vincent at vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
More information about the gmp-bugs
mailing list