Using a pre-computed array in another function?

Gabriel Risterucci cleyfaye at gmail.com
Sun Jul 8 18:40:09 CEST 2012


Just read your code again, you're assigning to the wrong A. So, in your
original sample:
1 - you miss initialization for all items in the A array
2 - you're working with a LOCAL variable named A, and then try to access
the GLOBAL variable named A.

There might be more error, but you should start here.

-- 
Cley Faye
http://cleyfaye.net



2012/7/8 Alasdair McAndrew <amca01 at gmail.com>

> I've initialized every variable, but still the error.  I don't think it's
> the program logic - I've run very similar programs without GMP with no
> troubles.   When I run the program through gdb I obtain the error:
>
> Program received signal SIGSEGV, Segmentation fault.
> 0xb7f8ee5a in __gmpz_set_str () from /usr/local/lib/libgmp.so.10
>
> The problem occurs when the variable A is accessed in the mpz_myfun
> function.
>
> Thanks,
> Alasdair
>
>
> On Sun, Jul 8, 2012 at 9:25 PM, Torbjorn Granlund <tg at gmplib.org> wrote:
>
> > Alasdair McAndrew <amca01 at gmail.com> writes:
> >
> >   Thanks for that, but I don't think that's the cause of it: I tested a
> > loop
> >   to print some of the A[i] values and they're all there.  It's just that
> > for
> >   some reason, the A[i] values are "invisible" to my mpz_myfun function.
> >
> > Certainly, mpz_t variables need to be initialised, whether scalar or in
> > an array.
> >
> > If your program malfunctions even with all variables properly
> > initialised, then your program has more bugs.  Then try to debug your
> > program using standard debugging techniques.
> >
> > www.cs.mtu.edu/~soner/Classes/CS-3411/Slides/05-Debug.pdf
> >
> > --
> > Torbjörn
> >
>
>
>
> --
> Blog: http://amca01.wordpress.com
> Web:  http://sites.google.com/site/amca01/
> Facebook: http://www.facebook.com/alasdair.mcandrew
> _______________________________________________
> gmp-discuss mailing list
> gmp-discuss at gmplib.org
> https://gmplib.org/mailman/listinfo/gmp-discuss
>


More information about the gmp-discuss mailing list