Maximum Size of an Array in FLINT?

20 Views Asked by At

I'm working on a project that uses the FLINT library, and I'm running into some problems defining a large fmpz array. Here's a minimal example of the problem

#include <iostream>
#include <fmpz_mod_poly.h>
#include <fmpz_mod.h>
#include<cstdlib>
#include<array>
using namespace std;
int main()
{
    //Here k is 2^20, I just used a bit shift trick to calculate it quickly
    //This does not run, but for int k  = 1<<19 it does run.
    int k = 1<<20;
    fmpz TestArray[k];
    for(int i = 1; i<=k;i++)
    {
        TestArray[i] = i;
    }
return 0;

and the error code is Thread 1: EXC_BAD_ACCESS (code=2, address=0x7ff7bf6ffff8).

If I replace the line

int k = 1 << 20;

with the line

int k = 1<<19;

then the program compiles with no error. I'm not sure what the issue is. I was under the impression that there was no maximum array size in C++.

0

There are 0 best solutions below