Ilya Zakharevich on Fri, 14 Jul 2000 17:15:41 -0400

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

Wrong layout of the return value of gpow()?

Here is the result I get from gpow():

(/opt/SUNWspro/bin/../WS5.0/bin/sparcv9/dbx) p RETVAL
RETVAL = 0x644460
(/opt/SUNWspro/bin/../WS5.0/bin/sparcv9/dbx) x 0x00644450/8
0x00644450:      0x00000004 0x02000003 0x40000003 0x00000001
0x00644460:      0x06000003 0x006e23a0 0x00644454 0x02000003
(/opt/SUNWspro/bin/../WS5.0/bin/sparcv9/dbx) p output(RETVAL)

As you can see, RETVAL[2] is less than RETVAL.  This causes a segfault
in Math::Pari.  Is it a bug?

The possible reason is the following chunk of trans1.c:

  427       case t_INTMOD:
  428         y=cgetg(3,tx); copyifstack(x[1],y[1]);
  429         y[2]=(long)powmodulo((GEN)x[2],n,(GEN)x[1]);
  430         return y;

I think the executed code looks like

  Mod(1,p) ^ (p - 1)

or some such.