t-get_ux error

14 views
Skip to first unread message

Jason

unread,
May 28, 2011, 6:36:56 AM5/28/11
to mpir-...@googlegroups.com
Hi
on gcc70 which is a netburstlahf running 64bit netbsd with gcc-4.1.3 we get
this error

PASS: t-get_d
PASS: t-get_d_2exp
PASS: t-get_si
PASS: t-get_sx
[1] Abort trap (core dumped) "${tst}" >t-get_...
FAIL: t-get_ux
PASS: t-hamdist
PASS: t-import
PASS: t-inp_str
PASS: t-io_raw
PASS: t-jac
PASS: t-lcm
PASS: t-likely_prime_p


we do get these warning when building the tests


ibtool: link: cc -std=gnu99 -O2 -m64 -march=nocona -mtune=nocona -o .libs/t-
get_si t-get_si.o ../../tests/.libs/libtests.a
/home/jasonmoxham/gcc70.fsffrance.org.06942a/gcc70.fsffrance.org.17184a/mpirbld/.libs/libmpir.so
../../.libs/libmpir.so -Wl,-rpath -Wl,/home/jason
moxham/gcc70.fsffrance.org.06942a/gcc70.fsffrance.org.17184a/install/lib
cc -std=gnu99 -DHAVE_CONFIG_H -I. -I../../../../mpir-2.4.0/tests/mpz -I../.. -
I../../../../mpir-2.4.0 -I../../../../mpir-2.4.0/tests -O2 -m64 -
march=nocona -mtune=nocona -c ../../../../mpir-2.4.0/tests/mpz/t-get_sx.c
../../../../mpir-2.4.0/tests/mpz/t-get_sx.c: In function 'check_data':
../../../../mpir-2.4.0/tests/mpz/t-get_sx.c:63: warning: implicit declaration
of function 'mpz_get_sx'
../../../../mpir-2.4.0/tests/mpz/t-get_sx.c: In function 'check_max':
../../../../mpir-2.4.0/tests/mpz/t-get_sx.c:102: warning: implicit declaration
of function 'mpz_set_sx'
/bin/ksh ../../libtool --tag=CC --mode=link cc -std=gnu99 -O2 -m64 -
march=nocona -mtune=nocona -o t-get_sx t-get_sx.o ../../tests/libtests.la
../../libmpir.la
libtool: link: cc -std=gnu99 -O2 -m64 -march=nocona -mtune=nocona -o .libs/t-
get_sx t-get_sx.o ../../tests/.libs/libtests.a
/home/jasonmoxham/gcc70.fsffrance.org.06942a/gcc70.fsffrance.org.17184a/mpirbld/.libs/libmpir.so
../../.libs/libmpir.so -Wl,-rpath -Wl,/home/jason
moxham/gcc70.fsffrance.org.06942a/gcc70.fsffrance.org.17184a/install/lib
cc -std=gnu99 -DHAVE_CONFIG_H -I. -I../../../../mpir-2.4.0/tests/mpz -I../.. -
I../../../../mpir-2.4.0 -I../../../../mpir-2.4.0/tests -O2 -m64 -
march=nocona -mtune=nocona -c ../../../../mpir-2.4.0/tests/mpz/t-get_ux.c
../../../../mpir-2.4.0/tests/mpz/t-get_ux.c: In function 'check_data':
../../../../mpir-2.4.0/tests/mpz/t-get_ux.c:64: warning: implicit declaration
of function 'mpz_set_ux'
../../../../mpir-2.4.0/tests/mpz/t-get_ux.c:65: warning: implicit declaration
of function 'mpz_get_ux'
/bin/ksh ../../libtool --tag=CC --mode=link cc -std=gnu99 -O2 -m64 -
march=nocona -mtune=nocona -o t-get_ux t-get_ux.o ../../tests/libtests.la
../../libmpir.la

the log is

-bash-4.1$ cat t-get_ux.log
FAIL: t-get_ux (exit: 134)
==========================
mpz_get_ux() failed for data on item 8


Jason

Jason

unread,
May 28, 2011, 12:12:12 PM5/28/11
to mpir-...@googlegroups.com

I think the error is that while t-get_sx.c has the constants postfixed by an
"L" in the t-get_ux.c we dont. However the constants go up to 64bit so an L
would break windows . What we need is the postfix for an intmax_t , I think we
can use CNST_LIMB(0xfffffffff...) as it should be an L on unix and LL on
windows

Jason

Jason

unread,
May 28, 2011, 1:46:46 PM5/28/11
to mpir-...@googlegroups.com
On Saturday 28 May 2011 17:12:12 Jason wrote:
> On Saturday 28 May 2011 11:36:56 Jason wrote:
> > Hi
> > on gcc70 which is a netburstlahf running 64bit netbsd with gcc-4.1.3 we
> > get this error
> >
> > PASS: t-get_d
> > PASS: t-get_d_2exp
> > PASS: t-get_si
> > PASS: t-get_sx
> > [1] Abort trap (core dumped) "${tst}" >t-get_...
> > FAIL: t-get_ux
> > PASS: t-hamdist
> > PASS: t-import
> > PASS: t-inp_str
> > PASS: t-io_raw
> > PASS: t-jac
> > PASS: t-lcm
> > PASS: t-likely_prime_p
> >
> >
> > we do get these warning when building the tests
> >
> >
> > ibtool: link: cc -std=gnu99 -O2 -m64 -march=nocona -mtune=nocona -o
> > .libs/t- get_si t-get_si.o ../../tests/.libs/libtests.a
> > /home/jasonmoxham/gcc70.fsffrance.org.06942a/gcc70.fsffrance.org.17184a/m
> > pi rbld/.libs/libmpir.so ../../.libs/libmpir.so -Wl,-rpath

> > -Wl,/home/jason
> > moxham/gcc70.fsffrance.org.06942a/gcc70.fsffrance.org.17184a/install/lib
> > cc -std=gnu99 -DHAVE_CONFIG_H -I. -I../../../../mpir-2.4.0/tests/mpz
> > -I../.. - I../../../../mpir-2.4.0 -I../../../../mpir-2.4.0/tests -O2
> > -m64 - march=nocona -mtune=nocona -c
> > ../../../../mpir-2.4.0/tests/mpz/t-get_sx.c
> > ../../../../mpir-2.4.0/tests/mpz/t-get_sx.c: In function 'check_data':
> > ../../../../mpir-2.4.0/tests/mpz/t-get_sx.c:63: warning: implicit
> > declaration of function 'mpz_get_sx'
> > ../../../../mpir-2.4.0/tests/mpz/t-get_sx.c: In function 'check_max':
> > ../../../../mpir-2.4.0/tests/mpz/t-get_sx.c:102: warning: implicit
> > declaration of function 'mpz_set_sx'
> > /bin/ksh ../../libtool --tag=CC --mode=link cc -std=gnu99 -O2 -m64 -
> > march=nocona -mtune=nocona -o t-get_sx t-get_sx.o
> > ../../tests/libtests.la ../../libmpir.la
> > libtool: link: cc -std=gnu99 -O2 -m64 -march=nocona -mtune=nocona -o
> > .libs/t- get_sx t-get_sx.o ../../tests/.libs/libtests.a
> > /home/jasonmoxham/gcc70.fsffrance.org.06942a/gcc70.fsffrance.org.17184a/m
> > pi rbld/.libs/libmpir.so ../../.libs/libmpir.so -Wl,-rpath

look at the code I dont see what you trying to do


mpz_set_ux(z, val[i]);
n = mpz_get_ux(z);
#if NLIMBS == 1
if(n && n != z->_mp_d[k++]) // THIS SHOULD BE 0 NOT k++ ???????????
{

and


if(z->_mp_size != k) // THIS SHOULD BE 1 NOT k ??????????????????
{
printf("mpz_get_ux() failed for length on item %d (mpz size: %d,
size: %d)\n", i, z->_mp_size, k);
abort();
}
if(z->_mp_alloc < k) // THIS SHOULD BE 1 NOT K ??????????????
{
printf("mpz_get_ux() failed for allocation on item %d (mpz alloc:
%d, size: %d)\n", i, z->_mp_alloc, k);
abort();
}

I cant see how this passed on any other machine ??
Jason


Jason

unread,
May 28, 2011, 2:13:59 PM5/28/11
to mpir-...@googlegroups.com
On Saturday 28 May 2011 18:46:46 Jason wrote:
> On Saturday 28 May 2011 17:12:12 Jason wrote:
> > On Saturday 28 May 2011 11:36:56 Jason wrote:
> > > Hi
> > > on gcc70 which is a netburstlahf running 64bit netbsd with gcc-4.1.3 we
> > > get this error
> > >
> > > PASS: t-get_d
> > > PASS: t-get_d_2exp
> > > PASS: t-get_si
> > > PASS: t-get_sx
> > > [1] Abort trap (core dumped) "${tst}" >t-get_...
> > > FAIL: t-get_ux
> > > PASS: t-hamdist
> > > PASS: t-import
> > > PASS: t-inp_str
> > > PASS: t-io_raw
> > > PASS: t-jac
> > > PASS: t-lcm
> > > PASS: t-likely_prime_p
> > >
> > >
> > > we do get these warning when building the tests
> > >
> > >
> > > ibtool: link: cc -std=gnu99 -O2 -m64 -march=nocona -mtune=nocona -o
> > > .libs/t- get_si t-get_si.o ../../tests/.libs/libtests.a
> > > /home/jasonmoxham/gcc70.fsffrance.org.06942a/gcc70.fsffrance.org.17184a
> > > /m pi rbld/.libs/libmpir.so ../../.libs/libmpir.so -Wl,-rpath
> > > -Wl,/home/jason
> > > moxham/gcc70.fsffrance.org.06942a/gcc70.fsffrance.org.17184a/install/li
> > > b cc -std=gnu99 -DHAVE_CONFIG_H -I. -I../../../../mpir-2.4.0/tests/mpz

> > > -I../.. - I../../../../mpir-2.4.0 -I../../../../mpir-2.4.0/tests
> > > -O2 -m64 - march=nocona -mtune=nocona -c
> > > ../../../../mpir-2.4.0/tests/mpz/t-get_sx.c
> > > ../../../../mpir-2.4.0/tests/mpz/t-get_sx.c: In function 'check_data':
> > > ../../../../mpir-2.4.0/tests/mpz/t-get_sx.c:63: warning: implicit
> > > declaration of function 'mpz_get_sx'
> > > ../../../../mpir-2.4.0/tests/mpz/t-get_sx.c: In function 'check_max':
> > > ../../../../mpir-2.4.0/tests/mpz/t-get_sx.c:102: warning: implicit
> > > declaration of function 'mpz_set_sx'
> > > /bin/ksh ../../libtool --tag=CC --mode=link cc -std=gnu99 -O2 -m64
> > > - march=nocona -mtune=nocona -o t-get_sx t-get_sx.o
> > > ../../tests/libtests.la ../../libmpir.la
> > > libtool: link: cc -std=gnu99 -O2 -m64 -march=nocona -mtune=nocona -o
> > > .libs/t- get_sx t-get_sx.o ../../tests/.libs/libtests.a
> > > /home/jasonmoxham/gcc70.fsffrance.org.06942a/gcc70.fsffrance.org.17184a
> > > /m pi rbld/.libs/libmpir.so ../../.libs/libmpir.so -Wl,-rpath
> > > -Wl,/home/jason
> > > moxham/gcc70.fsffrance.org.06942a/gcc70.fsffrance.org.17184a/install/li
> > > b cc -std=gnu99 -DHAVE_CONFIG_H -I. -I../../../../mpir-2.4.0/tests/mpz

> > > -I../.. - I../../../../mpir-2.4.0 -I../../../../mpir-2.4.0/tests
> > > -O2 -m64 - march=nocona -mtune=nocona -c
> > > ../../../../mpir-2.4.0/tests/mpz/t-get_ux.c
> > > ../../../../mpir-2.4.0/tests/mpz/t-get_ux.c: In function 'check_data':
> > > ../../../../mpir-2.4.0/tests/mpz/t-get_ux.c:64: warning: implicit
> > > declaration of function 'mpz_set_ux'
> > > ../../../../mpir-2.4.0/tests/mpz/t-get_ux.c:65: warning: implicit
> > > declaration of function 'mpz_get_ux'
> > > /bin/ksh ../../libtool --tag=CC --mode=link cc -std=gnu99 -O2 -m64
> > > - march=nocona -mtune=nocona -o t-get_ux t-get_ux.o
> > > ../../tests/libtests.la ../../libmpir.la
> > >
> > >
> > >
> > > the log is
> > >
> > > -bash-4.1$ cat t-get_ux.log
> > > FAIL: t-get_ux (exit: 134)
> > > ==========================
> > > mpz_get_ux() failed for data on item 8
> > >
> > >
> > > Jason
> >
> > I think the error is that while t-get_sx.c has the constants postfixed by
> > an "L" in the t-get_ux.c we dont. However the constants go up to 64bit so
> > an L would break windows . What we need is the postfix for an intmax_t ,
> > I think we can use CNST_LIMB(0xfffffffff...) as it should be an L on
> > unix and LL on windows
> >
> > Jason
>

my dinner was burning , looking at the code


> look at the code I dont see what you trying to do
>
>
> mpz_set_ux(z, val[i]);
> n = mpz_get_ux(z);
> #if NLIMBS == 1
> if(n && n != z->_mp_d[k++]) // THIS SHOULD BE 0 NOT k++
> ??????????? {
>
> and
>
>
> if(z->_mp_size != k) // THIS SHOULD BE 1 NOT k ??????????????????
> {
> printf("mpz_get_ux() failed for length on item %d (mpz size:
> %d, size: %d)\n", i, z->_mp_size, k);
> abort();
> }
> if(z->_mp_alloc < k) // THIS SHOULD BE 1 NOT K ??????????????
> {
> printf("mpz_get_ux() failed for allocation on item %d (mpz
> alloc: %d, size: %d)\n", i, z->_mp_alloc, k);
> abort();
> }
>
>
>
> I cant see how this passed on any other machine ??
> Jason

it looks like the ifdef I put in for VS2008 uintmax_t are wrong well

Jason

Cactus

unread,
May 28, 2011, 3:13:34 PM5/28/11
to mpir-devel
I assume here that mpz_set_ux is correct and that mpz_get_ux may be
wrong.

The variable k is the number of the limb that is about to be tested
and, after the test, the number of limbs that have been tested.

Note that k is initialised to zero.

> #if NLIMBS == 1
>         if(n && n != z->_mp_d[k++])  // THIS SHOULD BE 0 NOT k++  ???????????

When only one limb is used, if n is zero we don't want to test the
limb value and we don't increment k (i.e. no limbs)

Otherwide we test n against the the limb value and leave k equal to 1.

>        if(z->_mp_size != k)   // THIS SHOULD BE 1 NOT k  ??????????????????

When NLIMBS is 1 here, k will be 1 here when the number is non zero.

Here k is the number of limbs we have tested against the n value

>         {
>             printf("mpz_get_ux() failed for length on item %d (mpz size: %d,
> size: %d)\n", i, z->_mp_size, k);
>             abort();
>         }
>         if(z->_mp_alloc < k)  // THIS SHOULD BE 1 NOT K ??????????????
>         {
>             printf("mpz_get_ux() failed for allocation on item %d (mpz alloc:
> %d, size: %d)\n", i, z->_mp_alloc, k);
>             abort();
>         }
>
> I cant see how this passed on any other machine ??

Brian

Jason

unread,
Jun 5, 2011, 12:28:09 AM6/5/11
to mpir-...@googlegroups.com

I get it now , the line
uintmax_t k = 0, n;
got me confused , because it's a declaration I couldn't see that k gets set to
0 on every loop , DUH...

The error is a compiler bug , mpz_set_ux(z,0xFFFFFFFF) does the right thing
but n=mpz_get_ux(z) returns 0xFFFFFFFFFFFFFFFF so the line
return (uintmax_t)(z->_mp_size ? z->_mp_d[0] : 0);
is compiled wrong
I'll set up a test so we reject this compiler

Jason

Jason

unread,
Jun 5, 2011, 12:53:48 AM6/5/11
to mpir-...@googlegroups.com
> > > > > 18 4a/m pi rbld/.libs/libmpir.so ../../.libs/libmpir.so -Wl,-rpath
> > > > > -Wl,/home/jason
> > > > > moxham/gcc70.fsffrance.org.06942a/gcc70.fsffrance.org.17184a/instal
> > > > > l/ lib cc -std=gnu99 -DHAVE_CONFIG_H -I.

> > > > > -I../../../../mpir-2.4.0/tests/mpz -I../.. -
> > > > > I../../../../mpir-2.4.0 -I../../../../mpir-2.4.0/tests -O2
> > > > > -m64 - march=nocona -mtune=nocona -c
> > > > > ../../../../mpir-2.4.0/tests/mpz/t-get_sx.c
> > > > > ../../../../mpir-2.4.0/tests/mpz/t-get_sx.c: In function
> > > > > 'check_data': ../../../../mpir-2.4.0/tests/mpz/t-get_sx.c:63:
> > > > > warning: implicit declaration of function 'mpz_get_sx'
> > > > > ../../../../mpir-2.4.0/tests/mpz/t-get_sx.c: In function
> > > > > 'check_max': ../../../../mpir-2.4.0/tests/mpz/t-get_sx.c:102:
> > > > > warning: implicit declaration of function 'mpz_set_sx'
> > > > > /bin/ksh ../../libtool --tag=CC --mode=link cc -std=gnu99 -O2
> > > > > -m64 - march=nocona -mtune=nocona -o t-get_sx t-get_sx.o
> > > > > ../../tests/libtests.la ../../libmpir.la
> > > > > libtool: link: cc -std=gnu99 -O2 -m64 -march=nocona -mtune=nocona
> > > > > -o .libs/t- get_sx t-get_sx.o ../../tests/.libs/libtests.a
> > > > > /home/jasonmoxham/gcc70.fsffrance.org.06942a/gcc70.fsffrance.org.17
> > > > > 18 4a/m pi rbld/.libs/libmpir.so ../../.libs/libmpir.so -Wl,-rpath
> > > > > -Wl,/home/jason
> > > > > moxham/gcc70.fsffrance.org.06942a/gcc70.fsffrance.org.17184a/instal
> > > > > l/ lib cc -std=gnu99 -DHAVE_CONFIG_H -I.

We cant set up the test as the compiler tests are done before we know we have
stdint.h , so the test would also fail on any system without stdint , we could
require that on unix like systems we require stdint.h and inttypes.h (which
came in with the C99 standard)

Jason

Reply all
Reply to author
Forward
0 new messages