showing segmentation error for generating huge arrays

bodrato at bodrato at
Fri Jan 14 12:26:16 CET 2011

Hi Nimo,

You wrote me a private e-mail, please DON'T! Please, use the list!

In the code you sent me, you are using mpz_array_init to allocate the
"huge arrays" you mention in the subject of the e-mail...

My suggestion: if you are new to GMP library, avoid mpz_array_init.
Its description in the manual is full of warnings. I underline the
following two of them:
- "an application must ensure it [the space allocated] is sufficient for
any value stored"
- "the suggestion is to calculate in a regular mpz_init variable and copy
the result to an array variable with mpz_set".

I suggest you using {for (...) mpz_init(...)} instead, for experimenting.



More information about the gmp-discuss mailing list