Bill Allombert on Wed, 29 Nov 2017 17:37:32 +0100


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

Re: Segmentation Fault in PARI library related to factoru_pow()


On Wed, Nov 29, 2017 at 11:17:11AM -0500, Max Alekseyev wrote:
> This is my first attempt to use factoru_pow() function and I got
> 
>   ***   bug in PARI/GP (Segmentation Fault), please report.  ***   Error in
> the PARI system. End of program.
> 
> while running the following C++ code:
> 
> ====
> #include <iostream>
> #include <pari/pari.h>
> int main()
> {
>     pari_init(1ull<<30,1000);
>     GEN F = gel( factoru_pow(4), 3 ); // prime powers
>     long nf = glength(F);                      // number of prime powers
>     for(long i=1; i<=nf; ++i) {
>        std::cout << itos( gel(F,i) ) << std::endl;
>     }
>   return 0;
> }
> ====
> 
> Is anything wrong with my code and/or PARI library?

F is a t_VECSMALL, so you should do
F[i] and not itos( gel(F,i) )

Cheers,
Bill.