mardi 4 février 2020

Is there a size limit on the length of a std::array?

If I try to instantiate a large two-dimensional std::array on our Centos 7.6 system, compiled with g++ 7.3.1, I get a segmentation fault:

const unsigned NUM_BUFFERS = 200;
const unsigned BUFFER_SIZE_BYTES = 1024 * 1024;

std::array<std::array<unsigned char, BUFFER_SIZE_BYTES>, NUM_BUFFERS> buffer;

gives:

$ ./main
Segmentation fault (core dumped)

Is there a size limit on the length of a std::array?

I have declared this array on the stack but presumably the storage is on the free store. What is failing here?

Aucun commentaire:

Enregistrer un commentaire