Lengthy arrays and SIGSEGV

Jim White mathimagics at yahoo.co.uk
Sat Dec 17 15:34:37 CET 2005


> However, the following code  with an  
> ARRAY_SIZE of 700000 fails, but works with 600000.


> Changing the number of bits being allocated doesn't 
> seem to change the outcome.   

Have you tried looping yourself to init the array
elements?

Perhaps this isn't a GMP problem at all, rather the
way your compiler/platform handles fixed-size arrays.
The mpz_t structure itself is 4 words, or 16 bytes in
32-bit mode, so you are asking for an array of 10mb or
so.

On some systems a compiler might have a limit on the
size of a fixed array so it can use more efficient
short-reach addressing instructions. 

If this does apply, there may be a compiler option
that lets you get around it (e.g. on Intel-compatible
PC's there's a "memory model" option on most
compilers).

Alternatively you may need to allocate the array at
runtime.


Jim White



More information about the gmp-discuss mailing list